When you use HTML div blocks and the middle of the blocks cannot be tightly connected and you can't solve it 1. You can add a <head></head> in the middle content
Make the spacing between all blocks zero without conflicting with the padding margin below 2. There is a problem of spacing between the upper and lower divs I wrote 4 divs, distributed up and down, with spacing between them. The code and effect are as follows: .div1{ height:100px; background-color:blue; position:relative; } .div2 { height:100px; background-color:blueviolet; position:relative; } .div3{ height:100px; background-color:red; position:relative; } .div4{ height:100px; background-color:yellow; position:relative; } <body> <div class="div1" ></div> <div class="div2"></div> <div class="div3"></div> <div class="div4"></div> </body> Then, I tried to add margin:0 to each div to remove the spacing between the divs. The code is as follows:
The result remains the same, and there is still a gap, as shown below: Next I searched Baidu and found a method to set the font-size. The code and effect are as follows:
The above code focuses on adding body{font-size:0;}, and the effect is as follows: You can see that the gap between the top and bottom of the div has been eliminated. However, there is still a gap at the top and left. For this, I did this, adding body{margin:0px;}, the code is as follows:
The effect is as follows: As you can see, all the spacing has been eliminated. However, there is still a problem, that is, setting font-size:0; will cause all fonts to disappear. This is how I solved it: add a div inside a div and reset the font size of the inner div, for example: font-size: 30px;. Perfect solution! 3. After DIV+CSS clear:both clears the floating, there will be a gap above the div We know that sometimes using CSS float will produce CSS float. At this time, we need to clean up the float. We can use the clear style attribute to achieve it. However, after using clear:both to clear the resulting float, a white gap often appears above the div to which clear:both is applied. The solution is to add overflow:hidden to the div above this div;
Style Description:
This is the solution to the div gap caused by clear:both in recent days. Why use clear:both in div? This is mainly because the text in div b cannot be aligned to the left even if text-align:left is set in CSS, so clear:both is used in this case. A few questions: I will have the opportunity to study the above issues in detail in the future. Summarize: When clear:both is applied to a div to create a gap, overflow:hidden; needs to be added to the div of the same level above it to eliminate the gap. |
>>: How to implement HTML Table blank cell completion
CSS controls the printing style of web pages : Use...
Table of contents Angular accomplish Calling orde...
By default, Docker runs over a non-networked UNIX...
Preface: Due to my work, I am involved in the fie...
1. Configure local yum source 1. Mount the ISO im...
I think the commands I use most often are: Choice...
1. Replace your .js library file address with the...
I just learned mybatis today and did some simple ...
When executing yum in dockerfile or in the contai...
This article describes the import and export oper...
I am a beginner in SQL and thought that the insta...
First time using docker to package and deploy ima...
Table of contents Preface 1. Create a new Vue pro...
Several concepts Line box: A box that wraps an in...
Recently, the project switched the environment an...