The width of the parent container is fixed. In order to achieve that the child elements perfectly divide the parent width in equal proportion, what are the ways to achieve it? HTML part of the code: Method 1: Floating layout + percentage (Float the sub-elements to the left one by one, and set the width percentage of each sub-element according to the number of sub-elements) Method 2: Inline-block + percentage Method 3: Parent element display:table + child element display:table-cell Method 4: css3 display:flex; (flex layout) Method 5: Grid system (bootstrap) Add the class attribute The above five methods can all achieve the equal division of the parent element container into three equal parts, but the first two methods based on percentages cannot achieve perfect division into three equal parts, because the percentage is an inaccurate estimate, and if the child element has a border, it is difficult to divide it equally. The last three methods are preferred This is the end of this article about the implementation of CSS proportional division of parent containers (perfect thirds). For more relevant CSS proportional division of parent containers content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: TypeScript decorator definition
>>: Web realizes the code of popping up the window of uploading files by clicking the picture
As shown in the figure: Table Data For such a tre...
In the past, I only knew how to use the name attri...
Passive Check With passive health checks, NGINX a...
Table of contents 1. Forgot the root password and...
1. Background 1. The front end uses vue + vuex + ...
When using justify-content:space-between layout, ...
Table of contents definition The role of the curs...
Table of contents Overview Hash Properties Host p...
Case 1 vue-cli builds the vue3 project, uploads t...
Failure Scenario When calling JDBC to insert emoj...
Table of contents 1. Delete the old version 2. Ch...
Replication is to transfer the DDL and DML operat...
Preface As one of the best web servers in the wor...
Preface: MySQL master-slave architecture should b...
Database version: mysql> select version(); +--...