I am trying to recreate this image.
I however can’t figure out how to create the orange circle behind the image. I’ve trid using relative and absolute position but that did nothing and pushed other elements to the side. I have even tried to color the div parent element and give it border radius but that only caused some ugly lines to be visible on the sides.
This is my code.
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;700;800;900&display=swap');
:root{
--background: #f7f7ff;
--headerBackgroundColour: #ff9101;
--titles: #0b0b15;
--text: #555555;
--borders: #bbbbbb;
--dividers: #eeeeee;
--spacing: 1em;
--sectionSpacing: 4vw;
}
*{
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: 'Roboto';
text-decoration: none;
color: var(--text);
font-weight: 400;
}
.PageHeader{
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
}
.PageHeader div:nth-child(1){
width: 50%;
padding-left: var(--sectionSpacing);
padding-top: var(--sectionSpacing);
padding-bottom: var(--sectionSpacing);
}
.PageHeader div:nth-child(1) p:nth-child(1){
color: var(--titles);
}
.PageHeader div:nth-child(1) h1{
padding: 0;
font-weight: 900;
color: var(--titles);
font-size: 6em;
}
.PageHeader div:nth-child(1) h2{
color: var(--headerBackgroundColour);
font-weight: 700;
font-size: 2em;
}
.NavBar ul{
margin-top: var(--spacing);
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: center;
}
.NavBar li{
list-style: none;
}
.NavBar li a{
padding: var(--spacing);
border-radius: 5px;
}
.PageHeader .ImageContainer{
width: 50%;
display: flex;
flex-direction: column;
padding-right: var(--sectionSpacing);
}
.PageHeader .ImageContainer div{
width: 1000px;
height: 1000px;
background-color: var(--headerBackgroundColour);
position: absolute;
display: block;
border-radius: 50%;
}
.PageHeader .ImageContainer .Image{
display: inline-block;
width: 250px;
height: 250px;
background-color: red;
margin-left: var(--sectionSpacing);
}
.BioContainer{
background-color: whitesmoke;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css"/>
<title>Joe Doe</title>
</head>
<body>
<header class="PageHeader">
<div>
<p>Hello, My name is</p>
<h1>Joe Doe</h1>
<h2>Full-Stack Developer</h2>
<p>I design and develop services for customers of all sizes, specializing in creating stylish, modern websites, web services and online stores</p>
<nav class='NavBar'>
<ul>
<li><a href='#Biography'>Biography</a></li>
<li><a href='#MySkills'>What I Do?</a></li>
<li><a href='#Awards'>Awards</a></li>
<li><a href='#Experience'>Experience</a></li>
<li><a href='#Portfolio'>My Portfolio</a></li>
<li><a href='#Contact'>Contact</a></li>
</ul>
</nav>
</div>
<div class="ImageContainer">
<div></div>
<p class="Image">IMAGE</p>
</div>
</header>
</body>
</html>
2
Answers
Usually you can position the elements with
position: absolute
and setting thetop
orbottom
andleft
orright
property. You can learn more about it on https://www.w3schools.com/css/css_positioning.aspYou can adjust which element is over the other with the property
z-index
. You can learn more about it on https://www.w3schools.com/cssref/pr_pos_z-index.phpI have added a
z-index
to your image and adjusted thetop
andright
properties for both the image and the circle.This is a basic idea on how you could accomplish it with a block element that has a border radius set on it and with the parent hiding the overflow.
Other option is using an SVG or a clip path to trim the element.