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.
Table of contents Bubble Sort Selection Sort Inse...
1. When to execute setUp We all know that vue3 ca...
When starting MongoDB, the prompt is: error while...
【author】 Liu Bo: Senior Database Manager at Ctrip...
This article example shares the specific code for...
Table of contents 1. Check the status of the serv...
Preface In this article, we'll explore the ev...
1. Python installation 1. Create a folder. mkdir ...
This article example shares the specific code of ...
When it comes to databases, one of the most frequ...
Problem Description After installing workstations...
Nginx first decides which server{} block in the c...
First: via text/HTML var txt1="<h1>Tex...
Web Application Class 1. DownForEveryoneOrJustMe ...
1. Virtual environment follows the project, creat...