Placing a div next to the other

2

People have a problem with css, I wanted a div to be side by side. I have tried to put float in both, but if I do this the div footer goes up. What do I do?

#DivRodape{
position: absolute;
top: auto;
height: 35px;
line-height: 35px;
text-align: center;
width: 100%;
background-color:#004085;
}


#DivLateral{
position:relative;
border-width:2px;
width:300px;
height: 700px;
background-color: peachpuff;
}

#DivA{
position: relative;
border-width:2px;
width:auto;
height: auto;
left:300px;

}
    
asked by anonymous 11.12.2017 / 06:15

2 answers

1

@ J.Jones You have to use clear:both in the group to break the float when using Float in the elements. To solve your problem I created a Div on the outside named .group and in it I created a ::after pseudoelement and I used the style clear:both to clear the float and play the rodape down. Take a look at the code that you will understand.

OBS I made changes to your CSS just for you to better visualize what was done.

Click RUN to see the code working

#DivRodape{
    position: absolute;
    top: auto;
    height: 35px;
    line-height: 35px;
    text-align: center;
    width: 100%;
    background-color:#004085;
}
#DivLateral{
    position:relative;
    border-width:2px;
    width:100px;
    height: 100px;
    background-color: peachpuff;
    float: left;
}
#DivA{
    position: relative;
    border-width:2px;
    width: 100px;
    height: 100px;
    left:0px;
    background-color: red;
    float: left;
}
.group:before,
.group:after {
    content: "";
    display: table;
} 
.group:after {
    clear: both;
}
.group {
     zoom: 1; /* For IE 6/7 (trigger hasLayout) */
}
<div class="group">
    <div id="DivA"></div>
    <div id="DivLateral"></div>
</div>
<div id="DivRodape"></div>
  

Search for "Clear Fix CSS" and you will see several examples.

Here is a reference source in Portuguese link

    
11.12.2017 / 11:33
1

You have to put float: left in the two divs.

#DivLateral{
position:relative;
float: left;
border-width:2px;
width:300px;
height: 700px;
background-color: peachpuff;
}

#DivA{
position: relative;
float: left;
border-width:2px;
width:auto;
height: auto;
left:300px;

}
    
11.12.2017 / 09:50