简体   繁体   English

Chrome和IE10中的CSS对齐问题

[英]Issues with CSS alignment in Chrome and IE10

There're two issues I'm facing while I'm trying to make this page look the same way in all browsers. 当我试图使该页面在所有浏览器中看起来都一样时,我面临两个问题。

  1. I am using a fieldset tag <filedset></fieldset> for the login option. 我在登录选项中使用了<filedset></fieldset>标记<filedset></fieldset> It works fine with the latest version of Chrome and Firefox. 它可以与最新版本的Chrome和Firefox正常运行。 However, the output is little different in IE10. 但是,IE10中的输出几乎没有什么不同。

Here's the screenshot from Chrome. 这是Chrome的屏幕截图。

在此处输入图片说明

As you can see it's aligned with the top image. 如您所见,它与顶部图像对齐。

Here's how it looks like in IE10 这是IE10中的样子

在此处输入图片说明

The ending line of the <fieldset> tag is stopping in the middle of the page. <fieldset>标记的结尾行在页面中间停止。 How can I resolve this issue? 我该如何解决这个问题? I want the line to go all the way to the right same way as in Chrome. 我希望生产线一直沿用与Chrome中相同的方式。

Here is the html 这是HTML

            <fieldset>
                <legend><h3>Login to portal</h3></legend>
                </br>
                <strong>Username:</strong>&nbsp;&nbsp; <input type="text" id="text1"> 
                <br><br> 
                <strong>Password:</strong>&nbsp;&nbsp; <input type="password" id="text2"> 
                <br> <br />
                <asp:Button ID="btnLogin" runat="server" Height="41px" Text="Login" Width="74px" /> <br> 
            </fieldset>

Here's the CSS: 这是CSS:

fieldset {
border: 1px solid #cecfd5;
border-radius: 6px;
padding: 24px 30px;
}

The second issue I have is aligning the two textboxes and the button. 我遇到的第二个问题是对齐两个文本框和按钮。 As you can see the two text boxes are almost aligned but not perfectly and the button is just different position in every browser. 如您所见,这两个文本框几乎对齐但并不完美,并且按钮在每个浏览器中的位置都不同。 I want to align the button to the right side of the ending textboxes. 我想将按钮对齐到末尾文本框的右侧。

Here's the CSS I use for textboxes: 这是我用于文本框的CSS:

<style> 
#text1 
{ 
border: 2px solid rgb(173, 204, 204); 
height: 31px; 
width: 223px; 
box-shadow: 0px 0px 27px rgb(204, 204, 204) inset; 
transition:500ms all ease; 
padding:3px 3px 3px 3px; 
font-size: 20px;
color: #7D7764; 
} 

#text1:hover, #text1:focus 
 { 
 width:260px; 
 transition:500ms all ease; 
 background:url(images/email-icon.png) no-repeat right; 
 background-size:25px 25px; 
 background-position:96% 62%; 
 padding:3px 32px 3px 3px; 
 } 
 #text2
 { 
 border: 2px solid rgb(173, 204, 204); 
 height: 31px; 
 width: 223px; 
 box-shadow: 0px 0px 27px rgb(204, 204, 204) inset; 
 transition:500ms all ease; 
 padding:3px 3px 3px 3px; 
 font-size: 20px;
 color: #7D7764; 
  } 

  text2:hover, #text2:focus 
 { 
 width:260px; 
 transition:500ms all ease; 
 background:url(images/modify-key-icon.png) no-repeat right; 
 background-size:25px 25px; 
 background-position:96% 62%; 
 padding:3px 32px 3px 3px; 
 } 
 </style>

Any suggestions on how I can resolve these two issues? 关于如何解决这两个问题有什么建议吗?

Thanks 谢谢

UDPATE: I have resolved the second issue. UDPATE:我已经解决了第二个问题。 Still have issues with the first problem. 仍然有第一个问题的问题。

From the screenshot, it looks as though the <fieldset> is having display: block; 从屏幕快照中,看起来<fieldset>正在display: block; applied in chrome and FF, which is what causes it to expand to the maximum width available in the parent. 应用在chrome和FF中,这是使其扩展到父级中可用的最大宽度的原因。 The IE screenshot, however, looks as though it is having display: inline applied to it, which causes it to behave like a <span> , taking only as much space as is necessary to contain its child elements. 但是,IE屏幕快照看起来好像已经display: inline应用于它,这使其表现得像<span> ,仅占用包含其子元素所需的空间。

That's just how it looks, however. 但是,这就是它的外观。 I can't give a definitive answer without knowing what the style is that's actually being applied to the element. 在不知道实际应用于元素的样式的情况下,我无法给出明确的答案。 You can figure this out by pressing the f12 button while in IE10, that brings up their equivalent of debug tools. 您可以通过在IE10中按f12按钮来解决此问题,这将调出它们相当于调试工具的功能。 You'll want to look under the "computed" tab next to "styles" to see what the final style is that is being applied to the element. 您需要查看“样式”旁边的“计算”选项卡下,以查看最终应用于元素的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM