[英]Safari not recognizing negative margin-top
I have a fluid width container that has a shadow on the bottom. 我有一个宽度可变的容器,底部有一个阴影。 The margin has a negative top-margin and works fine in FF, Chrome, IE8+, but not in Safari.
边距的负边距为负,并且在FF,Chrome,IE8 +中可以正常工作,但在Safari中则不能。 In theory, I don't think I should even need a negative margin to make the shadow and inner portion stack, but apparently I do.
从理论上讲,我认为我甚至不需要负边距来制作阴影和内部部分的堆栈,但显然我确实需要。 Thoughts?
有什么想法吗?
HTML: HTML:
<div class="banner_wrap">
<div class="inner">
<div class="icon"></div>
<div class="text">
<p>OMG SO COOL, MAN</p>
</div>
</div>
<div class="shadow"></div>
</div>
CSS: CSS:
.banner_wrap {
float: left;
clear: none;
width: 100%;
max-width: none;
left: auto;
right: auto;
height: auto;
margin-bottom: 15px;
}
.banner_wrap .inner {
height:auto;
display:inline-block;
width:100%;
overflow:hidden;
position:relative;
}
.banner_wrap .shadow {
background: url(../shadow.png) 0 0 no-repeat;
height:12px;
background-size:100% 12px;
position:relative;
margin-top:-5px;
}
1. solution 1.解决方案
add vertical-align property and remove negative margin 添加垂直对齐属性并消除负边距
.banner_wrap .inner {
height:auto;
display:inline-block;
width:100%;
overflow:hidden;
position:relative;
background: #ddd;
vertical-align: top; /*this line*/
}
2. solution 2.解决方案
replace inline-block to block and remove negative margin 替换内联块以阻止并消除负边距
.banner_wrap .inner {
height:auto;
display:block;
width:100%;
overflow:hidden;
position:relative;
background: #ddd;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.