CSS Side-by-Side Divs with Equal Auto Widths
Achieving equal auto widths for child DIVs within a parent DIV can be tricky with traditional float and width approaches. However, using the display: table property provides a modern solution that enables this functionality.
Solution using Display: Table
CSS Example:
#wrapper { display: table; table-layout: fixed; width: 90%; height: 100px; background-color: Gray; } #wrapper div { display: table-cell; height: 100px; }
HTML Example:
Note:
- This solution is not compatible with IE7 and below.
- The provided JSFiddle examples demonstrate both three and two equal-width child DIVs.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3