To create a cover photo, use the background-image
property. For the user photo, utilize the img
tag. Next, place the img
element inside the cover photo and give it an upper offset by using an additional div
placed above the img
tag.
For a demonstration, check out this working example on CodePen.
Here is the CSS code:
.container {
background: red;
margin: auto;
width: 600px;
height: 300px;
background: #ddd;
}
header {
padding: 20px;
height: 140px;
background: url(https://static.pexels.com/photos/489/dawn-nature-sunset-night.jpg) center top;
background-size: cover;
}
.thumbnail {
width: 100px;
height: 100px;
background: #fff;
border: none;
}
.offset {
width: 100%;
height: 100px;
}
And here is the HTML code:
<div class="container">
<header>
<div class="offset"></div>
<img src="http://api.adorable.io/avatars/100/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f1e1d100b0b3f1e1b100d1e1d131a511610510f1118">[email protected]</a>" class="thumbnail" alt="user photo">
</header>
</div>