简体   繁体   中英

Why is span and form div not aligned in firefox

The following html&css works fine in chrome but on firefox it is not aligned

    <div class="btns">
    <div id="green">    
<span id="cls" class="btn btn-block btn-large btn-success disabled green_btn">Green</span>

    </div>
    <div id="red">
        <form class="button_to" >
            <div>
                <input class="btn btn-block btn-large btn-danger red_btn" type="submit" value="Red">
            </div>
        </form>
    </div>
</div>

css

#cls:hover {
    background:black;
    cursor:pointer;
}
.btns {
    position: relative;
}
.num {
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
}
#green, #red {
    display: inline-block;
    width: 49%;
    position: relative;
}
.green_btn, .red_btn {
    margin-bottom: 4px;
}

here is the jsfiddle

I don't understand why they are not aligned in firefox but in chrome they are fine.

You should use float: left; instead of inline-block;

Demo

Note : Don't forget to clear your floats

used to this

Define your #green, #red id vertical-align:top;

#green, #red {
    display: inline-block;
    vertical-align: top;}

Demo

More information about this

you just add float:left; above #red #green see the jsFiddle .

#green, #red {
    display: inline-block;
    width: 49%;
    position: relative;
    float:left;
}

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