【发布时间】:2017-09-19 11:02:01
【问题描述】:
我无法让复选框在各自的网格列中正确堆叠。我正在使用 ReactQL (jsx),所以我认为它不会在 code-sn-p 编辑器中正确显示。浮点数在这里没用。
/* checkboxes */
.section__checkboxes {
display: grid;
grid-template-columns: 2fr 4fr;
grid-column-gap: 2em;
}
.description {
grid-column: 1 / 2;
grid-row: 2 / 3;
}
.checkbox {
grid-column: 2 / 2;
grid-row: 2 / 3;
}
.choice {
grid-column: 2 / 3;
grid-row: 2 / 3;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div className={cn (css.section__checkboxes, css.section_wrapper)}>
<label className={css.description} htmlFor="checkbox_2">email notifications</label>
<input id="checkbox_2_1" name="checkbox_2_1" className={css.checkbox} type="checkbox" value="1" />
<label className={css.choice} htmlFor="checkbox_2_1">new direct messages</label>
<input id="checkbox_2_2" name="checkbox_2_2" className={css.checkbox} type="checkbox" value="1" />
<label className={css.choice} htmlFor="checkbox_2_2">new user signups</label>
<input id="checkbox_2_3" name="checkbox_2_3" className={css.checkbox} type="checkbox" value="1" />
<label className={css.choice} htmlFor="checkbox_2_3">new uploads</label>
</div>
【问题讨论】:
-
看起来您将所有元素放在同一个网格行上。你需要解决这个问题。