CSS is a style language. Among them, the realization of two divs side by side is a very common requirement. This article will introduce the various methods of CSS to realize the side-by-side display of two divs. It has certain reference value. If you are interested, you can learn about it.
Method 1: Float, float:left; is left floating, or it can be set to float:right; to float right, or two divs can be placed side by side in one row.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Method 2: display:table-cell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Method 3: Negative margin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Method 4: Absolute positioning
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Method five: flex layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
This concludes this article about the various methods of using CSS to display two divs side by side. I hope it can help you.
Reprinted from: Weidian Reading https://www.weidianyuedu.com