1. Floating layout 1. Let the fixed width div float first! Take it out of the document flow. .aside{ float: left; width: 200px; background-color: red; } .content{ margin-left: 200px; background-color: blue; } <div class="aside"> I have always been a very good person, and I have always been a very good person. I have always been a very good person, and I have always been a very good person. </div> <div class="content"> I have always been a very good person, and I have always been a very good person. I have always been a very good person, and I have always been a very good person. </div> 2. Negative value of margin (3 divs)
.aside{ float: left; margin-right: -200px; width: 200px; background-color: red; } .content{ float: right; } .content .inner{ margin-left: 200px; background-color: blue; } <div class="aside"> I have always been a very good person, and I have always been a very good person. I have always been a very good person, and I have always been a very good person. </div> <div class="content"> <div class="inner"> I am a very good person, and I am very happy with my work. I am very happy with my work. I am very happy with my work. I am very happy with my work. I am very happy with my work. I am very happy with my work. I am very happy with my work. </div> </div> 3.calc() calculation properties Note: When using calc to calculate properties, there must be spaces on both sides of the operator (- + etc.) Note that the two divs must float left and right. The width that must be subtracted from the calc width must be consistent with the fixed width. .aside{ float: left; width: 200px; } .content{ float: right; calc:(100% - 200px); } <div class="aside"> I have always been a very good person, and I have always been a very good person. I have always been a very good person, and I have always been a very good person. </div> <div class="content"> I have always been a very good person, and I have always been a very good person. I have always been a very good person, and I have always been a very good person. </div> 4.Flex layout
body{ display: flex; } .aside{ flex: 0 0 200px; background-color: red; } .content{ flex: 1; background-color:blue; } <div class="aside"> I have always thought that the world is full of energy, but I have always thought that the world is full of energy. I have always thought that the world is full of energy, but I have always thought that the world is full of energy! </div> <div class="content"> I am a very good person, very good at dealing with things. I am a very good person, very good at dealing with things, very good at being a good person, very good at being a good person. </div> 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. |
<<: JavaScript to achieve mouse drag effect
>>: 202 Free High Quality XHTML Templates (1)
Table of contents 1. Environmental Preparation 1....
1. Use xshell to connect to the virtual machine, ...
background Now the company's projects are dev...
Table of contents Loop - for Basic use of for loo...
Table of contents 1. Install axios 2. Use of axio...
When programmers do TypeScript/JavaScript develop...
Binlog is a binary log file that is used to recor...
Today, when I was using VMware to install a new v...
On Linux, bash is adopted as the standard, which ...
1. Set the parent container to a table and the ch...
Copy code The code is as follows: <!DOCTYPE HT...
1. Introduction to inode To understand inode, we ...
Table of contents 1. Implementation Background 2....
Apple Mug Icons and Extras HD StorageBox – add on...
1. Virtual Machine Preparation 1. Create a new vi...