Float:clear is not working with an element with relative position around it.
I have tried putting the float element in a div, changing display type of parent element. It does not work the expected way.
I am trying to avoid the overlap of child 2 element with Element 2.
My research failed to show the right way to make the above two work together.
Any guidance is appreciated.
Below is the screenshot of sample reference
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 90%;
//height: 550px;
margin: auto;
background-color: lightgrey;
margin-top: 15px;
border-radius: 15px;
}
.mainheader {
width: 100%;
height: 125px;
border-radius: 15px;
background-color: black;
}
.menu {
height: 30px;
background-color: seagreen;
position: relative;
top: 95px;
}
.main {
float: left;
padding: 10px;
width: 70%;
background-color: lightyellow;
//display: none;
}
.main img {
display: inline-block;
float: left;
margin: 12px;
width: 100px;
border-radius: 15px;
}
aside {
float: left;
/*width: 30%;
height: 40px;*/
background-color: lightyellow;
//display: none;
width: 30%;
text-align: center;
//outline: 1px blue solid;
//padding-bottom: 30px;
position: relative;
top: 30px;
}
.sidebar {
//outline: 1px gold solid;
//height: 350px;
/*position: relative;
top: 30px;*/
}
.cdiv article {
padding: 10px;
}
.content1 {
//border-radius: 15px;
//border: 1px red solid;
}
.content2 {
width: auto;
background-color: pink;
//border-radius: 15px;
//border: 1px red solid;
}
body .container .body aside .cdiv {
height: 100px;
width: 90%;
//margin-bottom: 10px;
background-color: yellow;
//border-radius: 10px;
display: inline-block;
}
footer {
clear: both;
width: 100%;
height: 40px;
background-color: red;
}
<!DOCTYPE html>
<html>
<title>MyHome</title>
<link rel="stylesheet" type="text/css" href="style.compact.css">
<body>
<div class="container">
<div class="mainheader">
<div class="header"></div>
<div class="menu"></div>
</div>
<div class="body">
<div class="main">
<div class="cdiv content1">
<img src="placeholder.jpg" alt="My logo">
<article>
<h2>My Site</h2>
<p>This is a test paragraph. This was supposed to be a long paragraph let see how this turns out. I have tried making as long as possible. But who is gonna type so much.</p>
<br>
<p>this is was test of new line lets find out how it works</p>
<br>
<p>This is a test paragraph. This was supposed to be a long paragraph let see how this turns out. I have tried making as long as possible. But who is gonna type so much.</p>
</article>
</div>
<div class="cdiv content2">
<article>
<h3>My Site</h3>
<p>This is a test paragraph. This was supposed to be a long paragraph let see how this turns out. I have tried making as long as possible. But who is gonna type so much.</p>
<br>
<p>this is was test of new line lets find out how it works</p>
<br>
<p>This is a test paragraph. This was supposed to be a long paragraph let see how this turns out. I have tried making as long as possible. But who is gonna type so much.</p>
</article>
</div>
</div>
<aside>
<div class="sidebar">
<div class="cdiv content3">
<div class="title"></div>
<div class="text"></div>
</div>
<div class="cdiv content4">
<div class="title"></div>
<div class="text"></div>
</div>
<div class="cdiv content5">
<div class="title"></div>
<div class="text"></div>
</div>
<div class="cdiv content6">
<div class="title"></div>
<div class="text"></div>
</div>
</div>
</aside>
</div>
<footer></footer>
</div>
</body>
</html>