HTML implements 2-column layout, with fixed width on the left and adaptive width on the right Implementation 1: <style> body, html{padding:0; margin:0;} // According to CSS positioning, use floating or absolute positioning to make the block element on the left out of the normal document flow and can be placed side by side with the block element on the right div:nth-of-type(1){ float: left; //Use floating// postion: absolute; //Use absolute positioning// top: 0; // left: 0; width: 300px; height: 200px; background: red; } // [Block-level elements automatically fill the width of the parent element by default and occupy one line] //Currently: right block element width = parent element width div:nth-of-type(2){ // Set margin-left to the width of the left block element. margin-left: 300px; // Now: the width of the right block element = parent element width - margin-left height: 220px; background: blue; } </style> <html> <div>div1</div> <div>div2</div> </html> 1) Before setting margin-left 2) After setting margin-left Implementation 2: <style> body, html{padding:0; margin:0;} // According to CSS positioning, use floating or absolute positioning to make the block element on the left out of the normal document flow div:nth-of-type(1){ float: left; //Use floating// postion: absolute; //Use absolute positioning// top: 0; // left: 0; width: 300px; height: 200px; background: red; } // FC is a normal (regular) document flow, formatting context, a rendering area in the page, and has a set of rendering specifications. BFC is a block formatting context. // Use the BFC block-level formatting context to create an isolated independent container div:nth-of-type(2){ // Change the overflow value to not visible, triggering BFC overflow: hidden; height: 220px; background: blue; } </style> <html> <div>div1</div> <div>div2</div> </html> 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. |
<<: An example of how to optimize a project after the Vue project is completed
>>: HTML5+CSS3 coding standards
Preface In general development, images are upload...
Table of contents Summarize <template> <...
For MySQL 5.5, if the character set is not set, t...
Hello everyone, I am Qiufeng. Recently, WeChat ha...
version: centos==7.2 jdk==1.8 confluence==6.15.4 ...
This article shares the specific code for JavaScr...
Table of contents 1. Install Docker 2. Create a c...
Websites without https support will gradually be ...
DOM Concepts DOM: document object model: The docu...
Table of contents What is front-end routing? How ...
How to install Linux CentOS 7.7 system in Vmware,...
1. Download the tomcat compressed package from th...
Table of contents Preface 1. The database name or...
Multi-table query Use a single select statement t...
This article uses an example to describe the erro...