-1

我有这个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 元素,但它应用于输入单选元素:

在此处输入图像描述

为什么不?我怎样才能让单选按钮也与其他元素一起以像素步长向东?

4

3 回答 3

3

尝试向!important您的代码添加异常:

.leftmarginbreathingroom {
    margin-left: 8px !important;
}
于 2016-05-05T23:14:48.193 回答
1

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

input { margin: 0 !important; }

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

于 2016-05-05T23:18:26.680 回答
0

不是crct,只是一个hack

<span className="text-white">hhh</span><input type="radio"  >...</input>
于 2022-01-27T20:40:12.623 回答