這個例子中, outer 比 container 高出幾個像素, 這個高度差是如何產生的? 如何消除?

2014-05-13 21:23:52 +08:00
 013231
http://jsfiddle.net/6tE9z/

<div id="outer">
<div id="container">
<div id="element">
some text
</div>
</div>
</div>

#container {
display: inline-block;
position: relative;
width: 50%;
}
#container:after {
content: '';
display: block;
margin-top: 100%;
}
#element {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: silver;
}

div {
margin: 0;
padding: 0;
}

#outer {
background-color: blue;
}
3804 次点击
所在节点    CSS
3 条回复
nijux
2014-05-13 22:22:51 +08:00
http://css-tricks.com/fighting-the-space-between-inline-block-elements/

#container {
display: inline-block;
position: relative;
width: 50%;
font-size:14px;
}
#container:after {
content: '';
display: block;
margin-top: 100%;
}
#element {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: silver;
}

div {
margin: 0;
padding: 0;
}

#outer {
background-color: blue;
font-size:0;
}
belin520
2014-05-13 23:33:26 +08:00
inline-block产生的
10yearsme
2014-12-05 12:28:44 +08:00
@belin520 Hi~我是广志,十年后(10years.me)的运营经理。我刚刚看到你的回答和v2ex上的其他交流,感觉和我们的技术和团队风格都挺合拍 ,希望可以聊聊。十年后是一个基于梦想的社交网络,我们想用它让年轻人的生活更有未来性,网站是去年年末上线的。我们上个月刚拿到创新谷VC百万元天使轮融资,现在在招募Web前端开发的人才。可以加我的微信lgz715314聊聊,交个朋友也不错:)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/112420

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX