The equal-width layout described in this article uses pure CSS to achieve the effect of making each element have the same width without manually setting the element width. 1. Use table-cell to implement (compatible with ie8) <style> body,div{ margin: 0; padding: 0; } .table-layout{ display: table;/*The parent element must be set to table*/ table-layout: fixed;/*This attribute must be present, otherwise the effect will not be achieved*/ width: 50%; margin: 20px auto; } .table-cell-layout{ display: table-cell;/*The child element must be set to table-cell*/ height: 40px; border: 1px solid #666; border-left: none; } .table-cell-layout:first-child{ border-left: 1px solid #666; } </style> <body> <ul class="table-layout"> <li class="table-cell-layout">li1</li> <li class="table-cell-layout">li2</li> <li class="table-cell-layout">li3</li> <li class="table-cell-layout">li4</li> <li class="table-cell-layout">li5</li> </ul> </body> 2. Use flex layout to achieve <style> body,div{ margin: 0; padding: 0; } .flex-layout{ display: flex; width: 50%; margin: 20px auto; } .flex-item{ flex: 1; height: 40px; border: 1px solid #666; border-left: none; } .flex-item:first-child{ border-left: 1px solid #666; } </style> <body> <ul class="flex-layout"> <li class="flex-item">li1</li> <li class="flex-item">li2</li> <li class="flex-item">li3</li> <li class="flex-item">li4</li> <li class="flex-item">li5</li> </ul> </body> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
>>: Getting Started Guide to Converting Vue to React
Is it the effect below? If so, please continue re...
How to change the MySQL database directory locati...
This article example shares the specific code of ...
The equal height layout described in this article...
structure body, head, html, title text abbr, acro...
The default request header of the http1.1 protoco...
As the demand for front-end pages continues to in...
This article shares the installation and configur...
Using c3p0 Import the c3p0jar package <!-- htt...
VC6.0 is indeed too old VC6.0 is a development to...
Table of contents 1. Listening for events 2. Pass...
There are many XHTML tags: div, ul, li, dl, dt, d...
Table of contents 1. Database Engine 1.1 View dat...
When faced with a SQL statement that is not optim...
As a useful terminal emulator, Xshell is often us...