hello people!
So I'm creating this website and I want to create a first div in wich the background color is navy, and another inside the first div were instead the background color is white and the second div contains all the content of the website, unfortunately everytime I set the margin for the second div, all the website contents get all influenced by the div margin, please help!!!
Instead of setting "margin" to the second div, set "padding" to the first div.
Hers is a basic example...
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>untitled document</title>
<style>
#first-div {
width:760px;
padding:20px;
margin:auto;
background-color:#000080;
}
#second-div {
padding:20px 20px 0;
background-color:#fff;
}
#second-div p {
margin:0;
padding-bottom:20px;
}
</style>
</head>
<body>
<div id="first-div">
<div id="second-div">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
ultricies sollicitudin nisi, ut molestie felis adipiscing sit
amet. Sed auctor vehicula commodo. Nam a nibh neque, vitae
faucibus felis. Vivamus at metus eget eros consequat fringilla.
Quisque magna magna, laoreet eu tempus sit amet, fringilla at
tellus. Praesent felis tortor, scelerisque vitae fringilla
non, porttitor et lacus. Ut ut sapien nec quam tincidunt
consectetur in nec lacus.
</p><p>
Phasellus porta, dui a elementum egestas, odio sapien rhoncus
lorem, vitae bibendum erat sem eget sapien. Maecenas ut metus
ac quam pellentesque lacinia quis sit amet augue. Fusce eu
euismod urna. Nunc volutpat scelerisque tempus. Donec eget arcu
et mauris scelerisque tristique. Donec fringilla mauris dolor,
sit amet vulputate lacus. Nulla feugiat mattis nulla non
tincidunt. Nam sit amet dolor eros, a viverra lacus. Nunc quis
nisi eget neque tempus facilisis eu quis sapien.
</p>
</div>
</div>
</body>
</html>
I tried but unfortunately it does the same thing all the content of the website gets shifted in on the right if I apply padding-left, or viceversa if I apply padding-right...
Bookmarks