简体   繁体   English

为什么span和form div在firefox中没有对齐

[英]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 以下html&css在chrome中运行良好,但在firefox上它没有对齐

    <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 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 这是jsfiddle

I don't understand why they are not aligned in firefox but in chrome they are fine. 我不明白为什么他们没有在firefox中对齐,但在chrome中它们很好。

You should use float: left; 你应该使用float: left; instead of inline-block; 而不是inline-block;

Demo 演示

Note : Don't forget to clear your floats 注意:别忘了清除浮子

used to this 习惯了

Define your #green, #red id vertical-align:top; 定义你的#green, #red id vertical-align:top;

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

Demo 演示

More information about this 关于此的更多信息

you just add float:left; 你只需添加float:left; above #red #green see the jsFiddle . 上面#red #green看到jsFiddle

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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