The reason is this
I was working on a company website these days and wanted to make a domineering map, so I thought of Baidu API
Then I went to the website and found the code. Unfortunately, the maximum width can only be 567px
But this is not suitable for For code experts, this is not a problem at all. Newbies like me also know how to change the source code
So I changed the width to 100%
Then the code for the first picture is like this
.top { height:100vh; width:100%; background:url(../images/background-1.jpg) no-repeat center top; background-size:cover;}
<section class="top">...</section>
1. Method 1 to prevent the image from breaking the DIV - TOP
The original processing method is to process the image to be displayed. For example, if your DIV width is 500px (pixels), then the width of the image you upload or place on the webpage must be less than 500px. That is to say, your image needs to be cut by image software and scaled down before uploading and placing it on the webpage. Solve the problem of broken and opened DIV.
It is common for many large picture sites and news sites to edit photos and images to adapt to the width of the web page.
2. Method 2 to prevent pictures from stretching the DIV - TOP
If you do not use the photo processing method to adapt to the limited width of the DIV, you can set the Hide Exceeding Content method on the DIV. You only need to set the width of the DIV and then add the CSS style "overflow:hidden" to solve the problem of the hidden image being too wide than the DIV and the problem of bursting the DIV.
3. Solution 3 - TOP
Just add the width to the image img tag to solve the problem. This can reduce the image proportionally without affecting the image quality.
For example, if your webpage DIV width is 500px, then you can set the width of the img tag to less than 500 after uploading the image.
This can solve the problem that the DIV SPAN is burst due to the picture being too wide. This has the advantage that the picture can be enlarged and reduced in equal proportions.
4. CSS method to solve the burst problem 4 - TOP
This method uses CSS to directly set the width of the img in the div. The bad thing about this is that if the image is too small, it will affect the effect of browsing the image on the web page.
Div structure:
1. Method 1 to prevent pictures from breaking the DIV - TOP