为什么我的左边距没有应用到我的单选按钮?

时间:2016-05-05 23:02:50

标签: html css twitter-bootstrap radio-button margin-left

我有这个CSS:

.leftmarginbreathingroom {
    margin-left: 8px;
}

...而且这个HTML:

<div class="row">
    <div class="col-md-12">
        <h4 class="h4 sectiontext leftmarginbreathingroom">Generate and Email Reports</h4>
    </div>
</div>

@* "On a specific day of the month" radio button and Day of month selection element *@
<div class="row">
    <div class="col-md-12">
        <input type="radio" id="groupRptGenerationAndSendingByDayOfMonth" class="leftmarginbreathingroom" value="day">On a specific day of the month:
        <select id="dayofmonthselect" class="leftmarginbreathingroom">
            @foreach (String day in daysOfMonth)
            {
                <option id="selItem_@(day) value=" day">@day</option>
            }
        </select>
        <label> of each month</label>
    </div>
</div>

@* "Based on a pattern" radio button and select elements *@
<div class="row">
    <div class="col-md-12">
            <input type="radio" id="groupRptGenerationAndSendingBasedOnAPattern" class="leftmarginbreathingroom" value="pattern">Based on a pattern
            <select id="ordinalselect" class="leftmarginbreathingroom">
                @foreach (String ord in ordinalWeeksOfMonth)
                {
                    <option id="selItem_@(ord) value=" ord">@ord</option>
                }
            </select>
            <select id="dayofweekselect">
                @foreach (String dow in daysOfWeek)
                {
                    <option id="selItem_@(dow) value="dow">@dow</option>
                }
            </select>
            <label> of each</label>
            <select id="weekormonthselect">
                @foreach (String pf in patternFrequency)
                {
                    if (pf == "Month")
                    {
                        <option id="selItem_@(pf)" value="@pf" selected="selected">@pf</option>
                    }
                    else
                    {
                        <option id="selItem_@(pf) value="pf">@pf</option>
                    }
                }
            </select>
    </div>
</div>

...然而,虽然左边距应用于h4元素和select元素,但应用于输入无线电元素:

enter image description here

为什么不呢?如何让单选按钮也以像素为单位向东移动到其他元素?

2 个答案:

答案 0 :(得分:3)

尝试在代码中添加!important例外:

.leftmarginbreathingroom {
    margin-left: 8px !important;
}

答案 1 :(得分:1)

输入元素有时会设置默认边距。你CSS中的某个地方可能有一个

input { margin: 0 !important; }

会阻止您的.leftmarginbreathingroom规则生效。为了解决这个问题,将!important添加到您的规则中会起作用。

相关问题