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
VMware Tools is a tool that comes with VMware vir...
1. Font properties color, specifies the color of ...
Pitfalls encountered I spent the whole afternoon ...
【1】Know the width and height of the centered elem...
Installation environment: CentOS7 64-bit, MySQL5....
Table of contents What is a listener in vue Usage...
Table of contents 1. Introduction to the connecti...
Use text-align, margin: 0 auto to center in CSS W...
Why mention textarea specifically? Because the tex...
Table of contents 1. What is dynamic typing? 2. D...
Unzip the file into a directory This is the direc...
Preface I just started learning MySQL and downloa...
"We're writing our next set of mobile pr...
This article example shares the specific code of ...
Apache Log4j2 reported a nuclear-level vulnerabil...