span在firefox中有偏移但在chrome中没有

时间:2013-02-28 08:39:06

标签: html css google-chrome firefox

我的HTML非常简单

<div class="btns">
    <div id="green">    <span 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

.btns {
    position: relative;
}

#green, #red {
    display: inline-block;
    width: 49%;
    position: relative;
}
.green_btn, .red_btn {
    margin-bottom: 4px;
}

正如您在此处所见http://jsfiddle.net/HajHV/9/

Chrome上的

看起来像这样

on chrome

但在firefox上

on firefox

我不明白这种差异。 html / css中没有任何内容对此有用。我该如何解决?

3 个答案:

答案 0 :(得分:2)

display: inline-block;添加到.green_btn, .red_btn {...}

答案 1 :(得分:1)

添加vertical-align:top

#green, #red {
    display: inline-block;
    width: 49%;
    position: relative; vertical-align:top
}

<强> DEMO

答案 2 :(得分:0)

或者,试试:

.btns {
    position: relative;
}

#green, #red {
    display: inline-block;
    width: 49%;
    position: relative;
}
.green_btn, .red_btn {
    margin-bottom: 4px;
}
#green {
    float:left;
}

#red {
    margin-left: 4px;
}