doyoe / blog Goto Github PK
View Code? Open in Web Editor NEWCSS探索之旅
Home Page: http://blog.doyoe.com/
CSS探索之旅
Home Page: http://blog.doyoe.com/
我实验了一下,在这篇文章中的对于临界值应该是要使#demo
和.b
元素不发生外边距折叠才有效的,我将代码该为如下:
#demo {
/*overflow: auto;*/
width: 400px;
margin: auto;
/*padding: 10px 0;*/
background: #ddd;
}
#demo div {
height: 30px;
}
.a {
float: left;
margin: 10px;
background: red;
}
.b {
clear: left;
background: green;
margin-top: 120px;
}
<div id="demo">
<div class="a">float:left</div>
<div class="b">clear:left</div>
</div>
这时候无论你如何设置b
元素的margin
,它都是在a
元素下方的20px
,当去除/*overflow: auto;*/
的注释后,b
元素的margin
就有效了,这里是触发了父元素的BFC
,而当注释掉/*overflow: auto;*/
,将/*padding: 10px 0;*/
注释去掉时,.b
元素的margin
还是有效,或者是为#demo
添加border
。外边距叠加collapsing-margin
不知道上面的理解是否有误,如有误还请指正:[email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.