简体   繁体   中英

Position div to left without float css

JS FIDDLE and the code below is what i did...can anyone help me...i want to do something like the second one but without using FLOAT

HTMl

   <div class="img-container">
        <div class="img"></div>Cristiano Ronaldo</div>
    <br>
    <br>
    <br>I want this but without using float can ayone help??
    <br>
    <br>
    <br>
    <div class="img-container">
        <div class="img" style="float:left;"></div>Cristiano Ronaldo</div>

CSS

div.img {
    height:60px;
    width:60px;
    border-radius:5px;
    background:brown;
    display:inline-block;
    margin-right:5px;
}

This is the css you need;

div.img {
    height:60px;
    width:60px;
    border-radius:5px;
    background:brown;
    display:inline-block;
    margin-right:5px;
        vertical-align:top;
}

If you remove the float inline style and add vertical-align: top; it works :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM