I would have expected the paragraph within the content body to align center with the page. Perhaps it’s my eyes but the paragraph doesn’t look center to me. It didn’t look centered when I watched the developer work through the project either. Do I have bad eyes or am I missing something here?
That didn’t fix my issue. I tried 95% then 90%. How would that even matter here. The .content width is 100% but the .content .body is a child of .content. So when we set margin for .content .body, which targets the p element inside of the .content div element wouldn’t that center it? Mind you when I followed the instructions of the lesson and when I changed it according to your suggestion the p (.content .body) was slightly left of center.
Please copy the URL in the location bar of the lesson page and paste it into a reply. We can have a look at the instructions and test our own solution.
I thought I posted the URL to the lesson in my topic opening. I titled it but it links to the lesson I’m looking at. Or are you asking for something else. Sorry for my confusion.
The box model is quite simple, when we break it down.
Given a content-box, of some width and possible height (height can be variable, controlled by the amount of content in the box) only the content and padding are inside the content-box. The border and margin are outside of the content-box (unless specified otherwise for border-box). If our content-box is 500px wide with a border of 10px and margin of 20px, our box-model will be 530px wide. If we have some specified height of say, 500px; the box-model will be 530px in total height.
Inside the content-box
content
padding
Outside the content-box
border
margin
offset (to be discussed when those properties come up)
Margins do not have any effect on the content-box, but padding has a direct effect. Until this is well understood and played around with, avoid using padding for the time being.
Hi! I was working on the same project and encountered the same error and found a solution. .body p is altering the margin of the content as well and preventing it from being altered! If you change .body p to something like:
.body p {
color: #333333;
font-weight: 100;
line-height: 34px;
width: 90%;
margin: 18px auto 0 auto;
}
In task 1 it says “Center the img horizontally using the margin property.” which I understood as:
nav {
text-align: center;
width: 180px;
margin: center;
}
But after changing the margin to auto, my “Davie’s Burgers” image and nav items (menu, nutrition, order, locations) became centered on the page and with the content. Example below:
nav {
text-align: center;
width: 180px;
margin: auto;
}