The second div is under the first. How to make them on the same line? let's say I make a slider:

<style> .content{ width: 400px; height: 300px; overflow: hidden; } .content div{ width: 400px; height: 300px; } </style><div class="content"> <div id="slide1"> </div> <div id="slide2" style="margin-left: 400px"> </div></div> 

(I change the margin to -400 and 0, respectively)

    1 answer 1

    There is a CSS property for divs (and not only for them), like "float". It is responsible for streamlining the container contents outside. Example:

     <div class="content"> <div id="slide1" style="float:left"> </div> <div id="slide2" style="margin-left: 400px; float:left"> </div></div> 
    • I know about this property, but there is no result. - SPAHI42
    • 2
      Maybe this is because the total length of two divs is greater than the width of the block in which they are placed? Make it rubber, specify the length of both divs = 50% or 40% - AseN
    • Yes, it worked as a percentage, ATP - SPAHI42