current position:Home>I set div to 100% in CSS, but it is not 100%. How should I solve it

I set div to 100% in CSS, but it is not 100%. How should I solve it

2022-02-02 20:24:27 CSDN Q & A

img

img

img




Refer to the answer 1:

This 100% Is relative to the parent element 100%, Look at the width of his parent element




Refer to the answer 2:



Refer to the answer 3:

div The width is based on the outer element Please check the width of the outer element and the inner margin of the outer element




Refer to the answer 4:



Refer to the answer 5:

This is 100%, Look at how the parent element is written css Of




Refer to the answer 6:



Refer to the answer 7:

css Add this

html,body {  margin: 0;  padding: 0;  width: 100%;  height: 100%;}

Then make sure you add the new one div Put it on body Next , If the new quilt is covered under another container , The width of each layer should be set 100%




Refer to the answer 8:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022024248275.html

Random recommended