For evenly distributed layouts, we generally use the negative margin method. The following figure shows an average layout. In this case, we usually add a div between the parent element and the child element, and then set a negative margin-right for this div, with the value being the distance between the two child elements. //HTML <div class="father"> <div class="middle"> <div class="son1"></div> <div class="son2"></div> <div class="son3"></div> </div> </div> //CSS .son1,.son2,son3{ margin-right:50px; width:100px; } .father{ width:400px; } .middle{ margin-right:-50px; } The middle layer margin-right:-50px is equivalent to "extending" 50px to the right, so that the son3 element has space to be in the same line as other elements. This concludes this article about examples of using CSS to achieve average layout with negative margins. For more information about CSS average layout with negative margins, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Simple implementation of html hiding scroll bar
>>: The effect of zooming in on a Taobao store is similar to the principle of using a slideshow.
CSS 3 animation example - dynamic effect of Tab b...
This article shares the specific code of JavaScri...
border-radius:10px; /* All corners are rounded wi...
Today, I will record how to install MySQL 8.0.18 ...
Today I will introduce two HTML tags that I don’t...
view: Views in MySQL have many similarities with ...
Using mock.js in Vue project Development tool sel...
I have been learning porters recently. I feel lik...
Installation environment: CentOS7 64-bit, MySQL5....
In CSS, text is one of the most common things we ...
Border Style The border-style property specifies ...
Table of contents Presentation Layer Business Lay...
Table of contents background analyze method backg...
This article example shares the specific code of ...
Mysql converts query result set into JSON data Pr...