I want my divs to act like in this JSfiddle. For some reason when I put an image inside one of them, it all starts to act a little crazy and I can't seem to figure out why. What am I doing wrong?
This is the JSfiddle with an image showing how it's acting strange.
HTML
<div class="divMain">
<div class="div2">
<p> some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text </p>
</div>
<div class="div3">
<p> some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text </p>
</div>
</div>
CSS
.divMain{
height: 500px;
width: 100%;
border: 2px solid black;
}
.div2{
display: inline-block;
height: 200px;
width: 40%;
border: 2px solid red;
}
.div2 img{
height: auto;
width: 80%;
}
}
.div3{
display: inline-block;
height: 200px;
width: 45%;
border: 2px solid blue;
}
@media only screen and (max-width: 500px) {
.div2{
background-color: red;
}
.div3{
background-color: blue;
}
}
}