Forum Moderators: not2easy
.content {
padding: 10px;
}
.call-to-action {
width: 100%;
margin: 0 auto;
background-color: blue;
}
<div class="content">
<h1>this is a headline that I want to be 10px away from the edges of the content div</h1>
<p>This is a paragraph that I also want to be 10px away from the edges of the content div</p>
</div> <!-- I am ending the content div here so I can put in a full width div -->
<div class="call-to-action">
Here is some text and stuff that I want the blue background color to start all the way to the edges of the content div</div>
<div class="content">
<p>Here is more text content that I want to be 10px away from the edge of the .content div</p>
.content {
padding: 0;
}
.content h1, .content h2, .content p {
margin: 0 10px;
}
if I have a content div with lots of text in it and that has a border, and I don't want the text and h1, h2, h3 tags to go all the way to the edges, but then I want to put a full-width image or call to action in that same div?
.container h1, .container h2, .container h3, .container p {margin-left: 2em; margin-right: 2em;}
.container p.call-to-action {margin-left: 0; margin-right: 0} Would it be better to remove the padding from the .content style and instead add MARGINS to the elements that are children / descendants of the content div?
<div class="content">
<h1>
this is a headline that I want to be 10px away
from the edges of the content div
</h1>
<p>
This is a paragraph that I also want to be 10px away
from the edges of the content div
</p>
<div class="call-to-action">
Here is some text and stuff that I want the blue background
color to start all the way to the edges of the content div
</div>
</div>
.content {
padding: 10px;
}
.call-to-action {
margin: 0 -10px;
background-color: blue;
}