I am a relatively new to the coding scene and I am trying to create my first responsive website. The page looks fine when the width is sufficiently large. However, when I test it on mobile devices or resize to a really small screen width, the "description" div overlaps onto the "profile pic". Is there a way where I can prevent this from happening? I've been trying for the past three days but to no avail. Trying my luck out here.
This is my code.
html, body {
height: 100%;
width: 100%;
font-family: 'Lora', serif;
background-color: lightgray
}
#navBarContainer {
height: 15%;
width: 100%;
display: flex;
align-items: center;
}
#contentPage {
display: flex;
height:75%;
width: 100%;
justify-content: center;
}
#container {
height: 100%;
width: 55%;
display: flex;
}
#profilePicContainer {
display: flex;
height: 100%;
width: 100%;
justify-content: center;
align-items: center;
position: relative;
}
img {
display: inline-block;
height: 70%;
border-radius: 200%;
position: absolute;
max-width: 100%;
max-height: 100%;
}
#image {
display: inline-block;
height: 100%;
width: 70%;
border-radius: 200%;
position: absolute;
max-width: 100%;
max-height: 100%;
background-color: black
}
#description {
height: 100%;
width: 100%;
margin-left: 2%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
}
#CoverPageName {
margin-left: 25%;
font-size: 200%
}
#navBarLinks {
margin-left: 10%;
display: flex;
justify-content: space-around;
width: 25%;
}
a {
color: black;
text-decoration: none;
}
#navBarFont {
font-size: 150%
}
#navBarFont:hover {
transition: 0.2s;
color: white
}
#helloFont {
text-align: center;
font-size: 400%
}
#circlesContainer {
height: 30%;
width: 100%;
display: flex;
justify-content: space-around;
}
.circles {
height: 100%;
width: 30%;
border-radius: 60%;
display: flex;
justify-content: center;
align-items: center;
font-size: 150%
}
#firstCircle {
background-color: #BFFCE7;
}
#firstCircle:hover {
background-color: #62B2C7;
transition: 0.3s
}
#secondCircle {
background-color: #F2D387;
}
#secondCircle:hover {
background-color: #C7AD6F;
transition: 0.3s
}
#thirdCircle {
background-color: #FC4245;
}
#thirdCircle:hover {
background-color: #C71B36;
transition: 0.3s
}
#personalSummary {
font-size: 125%
}
@media(max-width: 768px) {
#navBarContainer {
flex-direction: column;
}
#navBarLinks {
width: 100%
}
#CoverPageName {
margin-left: 0
}
#navBarLinks {
margin-left: 0
}
#contentPage {
height: 100%
}
#container {
width: 100%;
flex-direction: column;
}
#profilePicOuterContainer {
margin: 0 auto
}
#description {
margin: 0 auto
}
img {
height: 450px
}
#circlesContainer {
display: none;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Portfolio website</title>
<link href="https://fonts.googleapis.com/css?family=Lora" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id ="navBarContainer">
<a id="CoverPageName" href="index.html">NAME</a>
<div id="navBarLinks">
<a id="navBarFont" href="education.html">Education</a>
<a id="navBarFont" href="experience.html">Experience</a>
<a id="navBarFont" href="skills.html">Skills</a>
</div>
</div>
<div id="contentPage">
<div id="container">
<div id="profilePicContainer">
<div id="image"></div>
</div>
<div id="description">
<h1 id="helloFont" >Hi there,</h1>
<div id="circlesContainer">
<a class="circles" id="firstCircle" href="education.html">Education</a>
<a class="circles" id="secondCircle" href="experience.html">Experience</a>
<a class="circles" id="thirdCircle" href="skills.html">Skills</a>
</div>
<p id="personalSummary">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</body>
</html>