One way to put them side by side is with float:left
. I take it to say the property left
has no effect for elements statically positioned as is your case, and that display:block
is the display
by default for a <div>
Example with float:left
:
* {
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
width: 100%;
background-color: black;
}
.loren{
float:left; /*<---*/
width: 50%;
}
.ipsulum{
float:left; /*<---*/
width: 50%;
}
p {
margin: 5px;
font-family: Arial;
font-size: 15pt;
font-weight: bold;
background-color: gray;
color: white;
}
<div class="loren">
<p>Loren</p>
</div>
<div class="ipsulum">
<p>Ipsulum</p>
</div>
Another way of doing the same is with display:flex
which implies creating an element that encompasses the two divs:
* {
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
width: 100%;
background-color: black;
}
.loren{
width: 50%;
}
.ipsulum{
width: 50%;
}
p {
margin: 5px;
font-family: Arial;
font-size: 15pt;
font-weight: bold;
background-color: gray;
color: white;
}
.conteudo {
display:flex; /*<--*/
}
<div class="conteudo"> <!--div para conter os dois já existentes-->
<div class="loren">
<p>Loren</p>
</div>
<div class="ipsulum">
<p>Ipsulum</p>
</div>
</div>
Documentation: