(edited) My body's width is 1080px, but I'm trying to make a div that takes 100% width of the viewport which is larger than the body's width, for doing that I must use position: absolute; on it. But now I'm trying to put a line of text below that absolute div, but whatever I do it just will keep going above it, I've tried many ways but I couldn't fix it, please help. Here is my code:
body { width: 1080px; } .div { background: #f5f5f4; position: absolute; left: 0; right: 0; margin: 50px 0; height: 500px; } .text { display: block; margin: 20px; width: 100%; text-align: center; font-size: 0.8rem; color: #666; } <div class="div"></div> <p>text</p> Thanks in advance.
position: absolute;for making a div that is full width with another background color? By using this you are fixing the position of your div element. Remove that line and it will work correctly.