html - 如何将输入与多行文本的顶部对齐?
问题描述
我正在尝试将复选框与一些具有自定义行高的多行文本的顶部对齐。
我一直在搞砸,inline-grid
但如果没有固定的边距偏移,我想不出一个好方法来做到这一点。
这是我目前的方法:
.checkbox {
display: inline-grid;
grid-template-columns: auto auto;
line-height: 2;
}
.checkbox input {
margin-right: 10px;
}
<div style="max-width: 200px">
<div class="checkbox">
<input type="checkbox" />
<label>
Here is some text that wraps over multiple lines.
</label>
</div>
</div>
有人有任何建议/想法吗?
解决方案
尝试这个:
label { line-height: 2; }
label:first-line { line-height: 1; }
.checkbox {
display: inline-grid;
grid-template-columns: auto auto;
}
.checkbox input {
margin-right: 10px;
}
label{
line-height: 2;
}
label:first-line {
line-height: 1;
}
<div style="max-width: 200px">
<div class="checkbox">
<input type="checkbox" />
<label>
Here is some text that wraps over multiple lines.
</label>
</div>
</div>
推荐阅读
- angular - 在Angular 9中的两个选择上验证相同的值
- html - 如何使用 thymeleaf 或 Jquery 将参数从模态表单传递到 Spring Controller?
- javascript - 如何从 discord.js 中的 client.users.fetch(id) 获取值
- angular - 可观察 | 从 combineLatest 返回时,异步不维护组件中的数据,并带有 3 个单独的服务调用
- python - 如何在 SqlAlchemy 中使用过滤器扩展部分未知的查询?
- android - 地理编码器 getFromLocation 失败
- python - python中的语音识别模块太慢了
- r - R计算一个值在数据框中出现的次数
- javascript - 从后端rest api下载图像
- python - 使用最佳学习率会导致随机猜测准确度