Let’s say I have 3 div elements, wrapped in an article element. It would look something like this:
<article>
<div class="thumbnail-img">
<img src="the_source.jpg">
</div>
<div class="avatar">
<img src="the_avatar.jpg">
</div>
<div class="content">
<p>This is some content!</p>
</div>
</article>
Now, what I’d like to to is have that middle of class “avatar” to center vertically and horizontally between (overlap) the “thumb” and “content” divs.
It would look something like this:
Avatar centered between two div’s
As you can see, I’m working with WordPress. Specifically, creating a custom module for the Divi theme.
The CSS I have so far (which works pretty well, but is not 100% responsive – as in, the avatar does not always overlap centered between the 2 other div’s) is this:
.avatar {
margin-left: auto;
margin-right: auto;
max-width: 25%;
min-width: 70px;
position: relative;
}
.avatar img {
border-radius: 50%;
background-color: rgba(255,255,255,.2);
padding: 5px;
margin-top: -60%;
z-index: 10;
}
Here is a Fiddle if it helps: poor attempt
Happy to provide more info if needed. I’m just sure how to “word” this for search engines or here in SO. Thanks! 🙂
2
Answers
you can try this:
Here is the output
You could use the following style: