Horizontally space out my checkboxes using css? [closed]

落花浮王杯 提交于 2020-01-11 10:52:46

问题


I have a list of checkboxes that I'd like to have spaced out on a single horizontal line.

<div class="timesheet-daily-entry-fields-container">
        <input id="TimesheetMondayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetTuesdayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetWednesdayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetThursdayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetFridayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetSaturdayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
        <input id="TimesheetSundayCheckbox" class="timesheet-daily-checkbox" type="checkbox"/>
 </div>

They display on the line, but I'd like to space them out more.

.timesheet-daily-checkbox {
    margin: 10px;
    padding: 10px;
    display:inline-block;
    overflow:hidden
}

I'd rather not create a div around each input, is there an easier way?


回答1:


Increase the left and right margin

margin: 10px 20px;



回答2:


You can define the CSS class on the containing element's class AND the input tag, like this:

.timesheet-daily-entry-fields-container input {
    margin: 10px;
    padding: 10px;
    display:inline-block;
    overflow:hidden
}

That'll save you having to add a class to each input element. To space them out more, increase the margin.




回答3:


Wel you do not even have labels yet. Have you tried that? A label and some spaces would work wonders.



来源:https://stackoverflow.com/questions/12981746/horizontally-space-out-my-checkboxes-using-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!