In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the methods of setting div spacing CSS style layout in html". In daily operation, I believe that many people have doubts about the method of setting div spacing CSS style layout in html. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what are the methods of div spacing CSS style layout settings in html?" Next, please follow the editor to study!
1. Float realizes the div spacing of the dominant structure
Manipulate the structural layout, as usual, we use float:left and float:right to achieve, control settings to control the div sub-other width, it is important to count on the width to be good.
1. Look directly at the code
20px css5.com.cn.box {width:400px; border:1px solid # 999; overflow:hidden} .left {float:left; width:120px; height:100px; bac kilogram round: # CCC} .right {float:right; width:260px; height:100px; bac kg round:#06F}
2. Screenshot of effect
Control the float and complete the interval 20px between the left and right div
3, analysis summary: take float floating, complete two div respectively to the left and right, that is, close to the DIV spacing, assuming that the sum of the width of the two div is less than the parent width (forming div side by side), then there will be a gap between them, if the sum of their widths is greater than the parent width, they will occupy a unique line of dislocation. Here the width of the parent object of class=box is 400px, the width of child class=left is 120px, and the width of child class=right is 260px, so that a 20px partition can be generated between two div. Thus the spacing of div partition is realized.
2. Padding completes div interval effect
No matter the concave and convex structure or the distance between the DIV close to the left and right structure, are generally completed using padding, do not intend to occasionally important attention is to manipulate or high and low isolation distance typesetting is what kind of conditions, if there is no frame or backing gap, to complete the div interval in order to achieve the isolation distance between the modes, this time using padding is very convenient.
1. Code
Padding completes the spacing between DIV css5.com.cn.box {width:400px; border:1px solid # 999; overflow:hidden} .left {float:left; width:120px; height:100px; background:#CCC} .rights {float:left; padding-left:20px; width:260px; height:100px} .box2 {padding-top:30px} use padding-left to achieve the formal spacing between the left div and the right DIV to see the distance between the previous DIV and the previous DIV, so as to achieve the formal spacing between the previous DIV and the next DIV
2. Effectiveness
Css padding completes the function of manipulating and spacing between high and low.
3. Comprehensive summary: here padding is used to complete div spacing typesetting, which is required to construct the spacing between div boxes to complete the form. At this time, the root arrives at the need for no frame between the two div, while there is no background gap, although the use of padding structure partition effect in theory, the two div is close to each other, only borrowing the gap between the padding frame and the form, no backup, no frame gap, to complete the gap between the needs of the div.
Third, margin to achieve html div spacing
Compared with the padding configuration spacing, the margin configuration spacing does not need to think about whether the div can have a frame, whether the backing between the div is inconsistent, and under any premise, margin-left, margin-right, margin-top, margin-bottom may be used to complete the demand spacing.
1. Div isolation distance example code
Margin completes spacing typesetting between DIV css5.com.cn.box {width:400px; border:1px solid # 999; overflow:hidden} .left2 {float:left; width:120px; height:100px; bac kilogram round: # CCC} .right2 {float:left; margin-left:20px; bac kilogram round: # 09F; width:260px; height:100px} .box3 {margin-top:30px Border:2px solid # F00} use margin-left to complete the distance between left div and right DIV mode margin-top to achieve the distance between the previous DIV and the next DIV
2. Margin div spacing score
Css margin completes div spacing
3. Analysis summary: as usual, the spacing between div or other elements is realized by using margin external construction style. Early browsers' lack of compatibility with margin will lead to double value or double value achievement, but now tributary readers have supported it, but it is also necessary to master the layout distance between float and padding. The premise is to reduce the use of margin with value. Compatibility with margin:0 auto is not affected.
At this point, the study of "what are the methods of div spacing CSS style layout settings in html" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.