I am trying to use CSS properties to properly align article elements in a <div>
. I have three article elements which will have an image of an old website and a description along with a title. However, as you'll see in the code below, the header for the <div>
and the elements I want lined up are on one line. I want the header to be above the articles. [Edited for clarity]
HTML
<div id="website-examples">
<h1 class="section-header">Site Examples</h1>
<a href="#" title="Post 1">
<article>
<p>djsalkjadslgkjasdgljdg dsgkjlds;lgjdslkgjdslg jasd;lg dslgkj dslgj sljgs a</p>
<figure>
<img src="http://www.border7.com/blog/wp-content/uploads/2012/07/HTML.png">
<figcaption>Original Homepage</figcaption>
</figure>
</article>
</a>
<a href="#" title="Post 2">
<article>
<p>djsalkjadslgkjasdgljdg dsgkjlds;lgjdslkgjdslg jasd;lg dslgkj dslgj sljgs a</p>
<figure>
<img src="http://www.border7.com/blog/wp-content/uploads/2012/07/HTML.png">
<figcaption>Original Homepage</figcaption>
</figure>
</article>
</a>
<br>
<a href="#" title="Post 3">
<article>
<p>djsalkjadslgkjasdgljdg dsgkjlds;lgjdslkgjdslg jasd;lg dslgkj dslgj sljgs a</p>
<figure>
<img src="http://www.border7.com/blog/wp-content/uploads/2012/07/HTML.png">
<figcaption>Original Homepage</figcaption>
</figure>
</article>
</a>
</div>
CSS
#website-examples {
background-color: rgba(240, 237, 237, .5);
padding: 3% 10%;
column-width: 220px;
column-count: 3;
column-gap: 30px;
display: flex;
height: 500px;
}
#website-examples h1 {
margin-top: -30px;
margin-bottom: 100px;
width: 100%;
}
#website-examples a[title] {
text-decoration: none;
padding: 1rem;
color: #424242;
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .25);
display: inline-block;
height: 50%;
}
a[title] figure img {
width: 100%;
height: auto;
}
And here is the JSFiddle:
I don't see overlapping, but as in your comments, you wanted the header above the article columns, and not on the same line.
As what @MichaelCoker had stated, you should move the h1
tag above the #website-examples
tag:
<h1 class="section-header">Site Examples</h1>
<div id="website-examples">
--- some code here ... ---
Fiddle here ... (by @MichaelCoker)