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
This article uses examples to illustrate the usag...
1. Connect to MySQL Format: mysql -h host address...
Introduction to Linux top command The top command...
There are few and inadequate installation tutoria...
Purchase Certificate You can purchase it from Ali...
This script can satisfy the operations of startin...
Friends who are learning HTML, CSS and JS front-e...
Preface The apt-get command is a package manageme...
Just add the following code to achieve it. Method ...
1. Preparation Example: Two machines: 192.168.219...
MySQL trigger syntax details: A trigger is a spec...
Table of contents 1. v-if 2. Use v-if on <temp...
When writing my own demo, I want to use display:f...
Table of contents First install wget View Help Ma...
Problem Description 1. Database of the collection...