June 25, 201313 yr The current layout of my website is: Header: Width=1000 pixels Height=70 pixels Menu: Width=1000 pixels Height=34 pixels Images: Width=1000 pixels Height=82 pixels Text: Width=1000 pixels Height=automatically expands when content is added Footer: Width=1000 pixels Height=20 pixels The layout I want to change it too: Header: Width=full width of internet browser window Height=70 pixels Menu: Width=full width of internet browser window Height=34 pixels Images: Width=1000 pixels Height=82 pixels Text: Width=1000 pixels Height=automatically expands when content is added Footer: Width=full width of internet browser window Height=20 pixels This is my CSS code: #container { height: auto; width: 1000px; margin: auto; } #header { width: 1000px; height: 70px; background-image: url(images/headerbackground.fw.png); } #menu { width: 1000px; height: 34px; background-color: #00F; } #images { width: 1000px; height: 82px; background-image: url(images/imagesbackground.fw.png); } #text { width: 1000px; height: auto; min-height: 20px; background-color: #FFF; } #footer { width: 1000px; height: 20px; background-image: url(images/footerbackground.fw.png); text-align: right; } This is my HTML code: <div id="container"> <div id="header"></div> <div id="menu"></div> <div id="images"></div> <div id="text"></div> <div id="footer"></div> </div> Could someone tell me how I can change my CSS and/or HTML code to create the layout I mentioned above please? Thank you for any help.
June 25, 201313 yr Hi You can give your #container a width of 100%, so it takes full width of the browser window. Then adjust the widths of the other elements and use 100% width where you need the element to take full width of the browser window. You can also add margin:0 auto; to center some elements (if you need to). Hope that helps.
June 25, 201313 yr Author Hi You can give your #container a width of 100%, so it takes full width of the browser window. Then adjust the widths of the other elements and use 100% width where you need the element to take full width of the browser window. You can also add margin:0 auto; to center some elements (if you need to). Hope that helps. Thank you for your help, that worked. The only problem is, there seems to be a bit of white space around the outside of the container div, is there something I've done wrong? Here's the CSS as I've rewritten it: 1.#container { 2. height: auto; 3. width: 100%; 4. margin: auto; 5.} 6. 7.#header { 8. width: 100%; 9. height: 70px; 10. background-image: url(images/headerbackground.fw.png); 11.} 12. 13.#menu { 14. width: 100%; 15. height: 34px; 16. background-color: #00F; 17.} 18. 19.#images { 20. width: 1000px; 21. height: 82px; 22. background-image: url(images/imagesbackground.fw.png); 23.} 24. 25.#text { 26. width: 1000px; 27. height: auto; 28. min-height: 20px; 29. background-color: #FFF; 30.} 31. 32.#footer { 33. width: 100%; 34. height: 20px; 35. background-image: url(images/footerbackground.fw.png); 36. text-align: right; 37.} Have I done something wrong, or is there something I need to change? Thank you for any help. Edited June 25, 201313 yr by dandydan1152
June 25, 201313 yr Try adding: * {margin: 0; padding: 0;} Inside your CSS sheet. ^ This. But I'd recommend using a CSS Reset
June 26, 201313 yr Author Try adding: * {margin: 0; padding: 0;} Inside your CSS sheet. Thank you, I've added that code: #container { height: auto; width: 100%; margin: 0; padding: 0; } But I'm still having the same problem with the white space, is there anything else I can try? Thank you for any help.
June 26, 201313 yr give 100% width to container. it will show full screan.... Regards Ravi Tripathi Edited June 26, 201313 yr by teodora Removed link - not relevant
June 26, 201313 yr Did you use the reset that I suggested?Also, do you have a link or screenshot so we could see a visual example?
June 26, 201313 yr Author Did you use the reset that I suggested? Also, do you have a link or screenshot so we could see a visual example? I haven't tried the reset, because I wasn't sure what it did exactly, and whether I would have re-write the whole code again. I've uploaded a screenshot of what the problem is, you can see the white space at the top of the page (above the logo that says "Enjoy Leeds". Thank you for any help.
June 26, 201313 yr You need to do Alluzion's reset, what happens is different browsers automatically add padding, margin etc to items, not only divs but lists too etc. Do the reset then come back. body { margin: 0; padding: 0 }
June 26, 201313 yr Author I've tried changing my code to the following: #container { height: auto; width: 100%; margin-top: -8px; margin-left: -8px; margin-right: -8px; } This has fixed the white space at the top and to the left, but there is now a big white space to the right hand side (as you can see in the picture). Even though I have the width set to 100%. Edited June 26, 201313 yr by dandydan1152
June 26, 201313 yr Have you got a link? And you should do what Alluzion has suggested. It's not a big deal, it's just called a page reset, don't let the name scare you. You can create more problems with what you're trying now and the structure of your html matters too. Lets see your code and ideally a link would be better.
June 26, 201313 yr Author Have you got a link? And you should do what Alluzion has suggested. It's not a big deal, it's just called a page reset, don't let the name scare you. You can create more problems with what you're trying now and the structure of your html matters too. Lets see your code and ideally a link would be better. Thank you, I've used the CSS reset and it worked straight away. The only problem is that with the margins being set to negative values, it was cutting parts of the web page off. So I just had to set the negative values for the margins to 0, and then it worked fine. Thank you again.
Create an account or sign in to comment