Internet Explorer 中总是出现非常不寻常的边距 [CSS]
只有在 Internet Explorer 中才会发生这种情况:我在字段集下方获得了额外的边距(19 像素),但无论我尝试什么,我似乎都不明白为什么! 亲自尝试一下,看看 http://theshrop.com/d/call_us_or_call_in.php。 为了提供帮助,我添加了网格和一些背景颜色。 字段集应具有 1.125em 下边距,在 Safari、Firefox 等中也是如此。在 Internet Explorer 中它有额外的 19 像素吗? 我已经给了字段集一个宽度和高度,所以它有布局,希望这有帮助。
body{
color:#171717;
font:1em/1.125em Georgia,serif;
margin:0;
padding:0;
}
/* */
fieldset{
background:fuchsia;
border:0 solid green;
border-width:0.0625em 0;
height:19.125em;
margin:0 0 1.125em;
padding:3.3125em 1.125em 1.0625em;
position:relative;
width:31.5em;
}
/* */
form dl{
margin:0;
}
form dl dd{
/* */
height:2.25em;
margin:0 0 1.125em;
position:relative;
/* */
}
form dl dt{
margin:0 0 1.125em;
}
/* */
form dl dt+dd+dt+dd{
height:7.875em;
}
/* */
form dl+div{
line-height:2.25em;
/* */
margin:0;
padding:0;
/* */
}
h3{
color:#701;
font:bold 1em/1.125em Helvetica,Arial,serif;
margin:0 0 1.125em;
text-transform:uppercase;
}
input[type=text]{
border:0.0625em solid #171717;
font:1em/1.125em Georgia,serif;
height:1.125em;
margin:0;
padding:0.5em 1.0625em;
/* */
position:absolute;
top:0;
/* */
}
/* */
legend{
background:aqua;
margin:1.0625em 0 1.125em;
padding:0;
position:absolute;
top:0;
}
/* */
p{
background:lime;
margin:0 0 1.125em;
}
textarea{
border:0.0625em solid #171717;
font:1em/1.125em Georgia,serif;
height:6.75em;
margin:0;
padding:0.5em 1.0625em;
/* */
position:absolute;
top:0;
/* */
}
.Address{
margin:0 0 1.125em;
}
.Address dd{
margin:0;
}
.Address dt{
display:none;
}
.Address dt+dd+dt+dd{
display:inline;
}
.Address dt+dd+dt+dd+dt+dd+dt+dd{
display:block;
text-transform:uppercase;
}
.Bad{
background:#dbb;
color:#901;
}
.Calendar{
list-style:none;
margin:0;
padding:0;
}
.Calendar dd{
background:#701;
font:bold 0.5625em/2em Helvetica,Arial,serif;
margin:0;
text-align:center;
text-transform:uppercase;
}
.Calendar dl{
border:0 solid #111;
border-width:0.0625em 0.125em 0.125em 0.0625em;
float:left;
margin:-0.0625em 1em 1em 1.0625em;
width:3.375em;
}
.Calendar dt{
display:none;
}
.Calendar dt+dd+dt+dd{
background:#fff;
color:#171717;
font:1em/2.25em Georgia,serif;
margin:0;
}
.Calendar h4{
float:right;
font:1em/1.125em Georgia,serif;
margin:0 0 1.125em;
width:10.125em;
}
.Calendar li{
clear:both;
}
.Calendar p{
float:right;
font:1em/1.125em Georgia,serif;
width:10.125em;
}
.Good{
background:#bdb;
color:#091;
}
.Left{
float:left;
margin:0 0.5625em 0 1.125em;
}
.Message{
border-style:solid;
border-width:0.0625em;
margin:0 0 1.125em;
padding:1em 1.0625em 0;
}
.Message p{
margin:0 0 1.0625em;
padding:0.0625em 0 0;
}
.Narrow{
width:15.75em;
}
.Narrow input[type=text]{
width:13.5em;
}
.Right{
float:right;
margin:0 1.125em 0 0.5625em;
}
.Wide{
/* */
background:gray;
/* */
width:31.5em;
}
.Wide input[type=text]{
width:29.25em;
}
.Wide textarea{
width:29.25em;
}
.Wrapper{
background:url(../i/grid_w18_h18.png);
margin:0 auto;
overflow:hidden;
padding:1.125em 0 0;
position:relative;
width:50.625em;
}
#Blackboard{
background:#171717;
color:#fff;
margin:1.125em 0 0;
min-width:50.625em;
}
#Blackboard a{
background:#111;
color:#fff;
}
#Blackboard h3{
color:#fff;
}
#Blackboard div>p{
font:1.5em/1.5em Georgia,serif;
}
#Footer{
background:#901;
clear:both;
color:#fff;
min-width:50.625em;
}
#Footer h3{
color:#fff;
}
#Google_Copilot ol{
padding:0;
}
#Google_Copilot ol li{
list-style:none;
margin:0 0 1.125em;
padding:0; /* I.E.7 Fix */
}
#Google_Map{
height:23.625em;
margin:0 0 1.125em;
width:31.5em;
}
#Google_Query dt{
/* display:none; */
}
#Header{
background:#901;
min-width:50.625em;
}
#Header h1{
background:url(../i/the_shropshire_arms_w288_h72.gif) no-repeat 0 2.8125em;
font:1em/1.125em serif;
height:7.875em;
margin:0 0 0 0.5625em;
width:18em;
}
#Header h1 a{
display:none;
}
#Header h2{
background-color:#933;
display:inline;
font:1em/2.25em Georgia,serif;
left:0;
margin:1.125em 0 0 0.5625em;
padding:0 0.5625em;
position:absolute;
top:0;
}
#Header h2 a{
color:#fff;
text-decoration:none;
}
#Header h2 a span{
text-decoration:underline;
}
#Header ul{
list-style:none;
height:2.25em;
margin:0;
padding:0;
}
#Header ul li{
display:inline; /* I.E.7 Fix */
}
#Header ul li a{
background:#fff;
color:#000;
float:left;
line-height:2.25em;
margin:0 0 0 0.5625em;
padding:0 0.5625em;
text-decoration:none;
}
#Header .Wrapper{
background:url(../i/shield_w126_h126.gif) no-repeat 42.1875em 1.6875em;
}
这篇文章可能会变得非常长,所以我将提供一个网页链接,而不是发布 HTML:http ://theshrop.com/d/call_us_or_call_in.php
我非常感谢答案和所有贡献者,提前致谢!
Only in Internet Explorer does this occur: I'm getting an additional margin (of 19 pixels) below a fieldset and I can't seem to see why, whatever I try! Try it for yourself, take a look at http://theshrop.com/d/call_us_or_call_in.php. To aid I've added a grid and some background colours. The fieldset should have a 1.125em bottom margin and it does in Safari, Firefox etc. It has an extra 19 pixels in Internet Explorer? I've given the fieldset a width and height so it hasLayout, hope this helps.
body{
color:#171717;
font:1em/1.125em Georgia,serif;
margin:0;
padding:0;
}
/* */
fieldset{
background:fuchsia;
border:0 solid green;
border-width:0.0625em 0;
height:19.125em;
margin:0 0 1.125em;
padding:3.3125em 1.125em 1.0625em;
position:relative;
width:31.5em;
}
/* */
form dl{
margin:0;
}
form dl dd{
/* */
height:2.25em;
margin:0 0 1.125em;
position:relative;
/* */
}
form dl dt{
margin:0 0 1.125em;
}
/* */
form dl dt+dd+dt+dd{
height:7.875em;
}
/* */
form dl+div{
line-height:2.25em;
/* */
margin:0;
padding:0;
/* */
}
h3{
color:#701;
font:bold 1em/1.125em Helvetica,Arial,serif;
margin:0 0 1.125em;
text-transform:uppercase;
}
input[type=text]{
border:0.0625em solid #171717;
font:1em/1.125em Georgia,serif;
height:1.125em;
margin:0;
padding:0.5em 1.0625em;
/* */
position:absolute;
top:0;
/* */
}
/* */
legend{
background:aqua;
margin:1.0625em 0 1.125em;
padding:0;
position:absolute;
top:0;
}
/* */
p{
background:lime;
margin:0 0 1.125em;
}
textarea{
border:0.0625em solid #171717;
font:1em/1.125em Georgia,serif;
height:6.75em;
margin:0;
padding:0.5em 1.0625em;
/* */
position:absolute;
top:0;
/* */
}
.Address{
margin:0 0 1.125em;
}
.Address dd{
margin:0;
}
.Address dt{
display:none;
}
.Address dt+dd+dt+dd{
display:inline;
}
.Address dt+dd+dt+dd+dt+dd+dt+dd{
display:block;
text-transform:uppercase;
}
.Bad{
background:#dbb;
color:#901;
}
.Calendar{
list-style:none;
margin:0;
padding:0;
}
.Calendar dd{
background:#701;
font:bold 0.5625em/2em Helvetica,Arial,serif;
margin:0;
text-align:center;
text-transform:uppercase;
}
.Calendar dl{
border:0 solid #111;
border-width:0.0625em 0.125em 0.125em 0.0625em;
float:left;
margin:-0.0625em 1em 1em 1.0625em;
width:3.375em;
}
.Calendar dt{
display:none;
}
.Calendar dt+dd+dt+dd{
background:#fff;
color:#171717;
font:1em/2.25em Georgia,serif;
margin:0;
}
.Calendar h4{
float:right;
font:1em/1.125em Georgia,serif;
margin:0 0 1.125em;
width:10.125em;
}
.Calendar li{
clear:both;
}
.Calendar p{
float:right;
font:1em/1.125em Georgia,serif;
width:10.125em;
}
.Good{
background:#bdb;
color:#091;
}
.Left{
float:left;
margin:0 0.5625em 0 1.125em;
}
.Message{
border-style:solid;
border-width:0.0625em;
margin:0 0 1.125em;
padding:1em 1.0625em 0;
}
.Message p{
margin:0 0 1.0625em;
padding:0.0625em 0 0;
}
.Narrow{
width:15.75em;
}
.Narrow input[type=text]{
width:13.5em;
}
.Right{
float:right;
margin:0 1.125em 0 0.5625em;
}
.Wide{
/* */
background:gray;
/* */
width:31.5em;
}
.Wide input[type=text]{
width:29.25em;
}
.Wide textarea{
width:29.25em;
}
.Wrapper{
background:url(../i/grid_w18_h18.png);
margin:0 auto;
overflow:hidden;
padding:1.125em 0 0;
position:relative;
width:50.625em;
}
#Blackboard{
background:#171717;
color:#fff;
margin:1.125em 0 0;
min-width:50.625em;
}
#Blackboard a{
background:#111;
color:#fff;
}
#Blackboard h3{
color:#fff;
}
#Blackboard div>p{
font:1.5em/1.5em Georgia,serif;
}
#Footer{
background:#901;
clear:both;
color:#fff;
min-width:50.625em;
}
#Footer h3{
color:#fff;
}
#Google_Copilot ol{
padding:0;
}
#Google_Copilot ol li{
list-style:none;
margin:0 0 1.125em;
padding:0; /* I.E.7 Fix */
}
#Google_Map{
height:23.625em;
margin:0 0 1.125em;
width:31.5em;
}
#Google_Query dt{
/* display:none; */
}
#Header{
background:#901;
min-width:50.625em;
}
#Header h1{
background:url(../i/the_shropshire_arms_w288_h72.gif) no-repeat 0 2.8125em;
font:1em/1.125em serif;
height:7.875em;
margin:0 0 0 0.5625em;
width:18em;
}
#Header h1 a{
display:none;
}
#Header h2{
background-color:#933;
display:inline;
font:1em/2.25em Georgia,serif;
left:0;
margin:1.125em 0 0 0.5625em;
padding:0 0.5625em;
position:absolute;
top:0;
}
#Header h2 a{
color:#fff;
text-decoration:none;
}
#Header h2 a span{
text-decoration:underline;
}
#Header ul{
list-style:none;
height:2.25em;
margin:0;
padding:0;
}
#Header ul li{
display:inline; /* I.E.7 Fix */
}
#Header ul li a{
background:#fff;
color:#000;
float:left;
line-height:2.25em;
margin:0 0 0 0.5625em;
padding:0 0.5625em;
text-decoration:none;
}
#Header .Wrapper{
background:url(../i/shield_w126_h126.gif) no-repeat 42.1875em 1.6875em;
}
This post could get stupidly long so I'll provide a link to the Web page rather than post the HTML: http://theshrop.com/d/call_us_or_call_in.php
I really appreciate answers and all who contribute, thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
老实说,甚至很难判断发生了什么,而且该页面在我尝试过的每个浏览器中看起来都不同。
不过有一些提示:
1 - 所有浏览器都有自己的元素基本边距等,因此最好使用某种“重置”CSS,这使得每个边距/填充为 0,这样当您用自己的方式指定它时css,每个浏览器都会解释元素的相同数量的边距/填充。 Eric Meyer 制作了一个非常流行的版本: http:// /meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/
2 - 设置高度可能是这里问题的一部分。 通常最好让内部元素设置高度,并让包含元素自然流动。 在您的情况下,字段集内的所有内容都应该告诉它有多高,而不是字段集有自己的高度。
只是一些大概的想法,希望对你有帮助。
Honestly, it's hard to even tell what's going on, and that page looks different in every browser I've tried.
A few tips though:
1 - All browsers have their own base margins etc for elements, so it's a good idea to use some sort of "reset" css, which makes every margin/padding 0, so that when you specify it with your own css, every browser interprets the same amount of margin/padding for an element. A very popular version of this was made by Eric Meyer: http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/
2 - Setting the height can be part of the problem here. It's usually best to let the internal elements set the height, and just let the containing element flow naturally. In your case, everything inside of the fieldset should be telling it how high to be, instead of the fieldset having it's own height.
Just some general thoughts, hope it helps.