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)
This article shares the specific code of JavaScri...
Preface In the previous article, I shared with yo...
Table of contents Reactive Function usage: toRef ...
As you build and scale your Django applications, ...
HTML: Title Heading is defined by tags such as &l...
Preface My needs are syntax highlighting, functio...
Overview There are many open source network monit...
Table of contents 1. Cross-domain filter CorsFilt...
Table of contents 1. Basic overview of the proces...
mysql gets all dates or months in a time period 1...
Use of stored procedure in parameters IN paramete...
One environment Install VMware Tools on CentOS 7 ...
Solution to 1449 and 1045 exceptions when connect...
As the first article of this study note, we will ...
In general : [1 important flag] > [4 special fl...