我在Firefox浏览器中使用负边距遇到了问题。负边距在Chrome浏览器中可以正常工作,但在Firefox浏览器中不行。
.search-bar {
height: 108px;
position: relative;
margin-top: -10px;
}
该解决方案的简单方法:
.search-bar {
height: 98px;
position: relative;
top: -10px;
}
我用相同的值将 margin-top
替换为 top
,然后将 height
减少了旧的 margin-top
值,结果非常好。
display:inline-block;
属性,这样它在Firefox浏览器中才能正常工作,或者您也可以使用 float:left
。如果 display: inline-block;
或 float:left
破坏了宽度问题,请再加上 width: 100%;
。 - Deepak Yadavfloat:left
。感谢@Deepak Yadav提供的解决方案。我做了这个,而且非常完美地运行。
.your__class{
display:inline-block;
vertical-align:top;
margin-top:-100px;
}
我的示例:
div span {
display: inline-block;
top: -10px;
width: 100%;
height: 3px;
line-height: 40px;
position: relative;
}