Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 当多行使用顺风CSS时,使用复选框将标签居中_Html_Css_Tailwind Css - Fatal编程技术网

Html 当多行使用顺风CSS时,使用复选框将标签居中

Html 当多行使用顺风CSS时,使用复选框将标签居中,html,css,tailwind-css,Html,Css,Tailwind Css,我有一个带有标签的复选框,有时它不止一行。如何将第一条直线中心与复选框对齐 <label class="inline-block"> <input class="ml-2 mr-1 mb-1 inline-block" data-id="{{inputDataId}}" type="checkbox" class="{{class}}" {% if required %} req

我有一个带有标签的复选框,有时它不止一行。如何将第一条直线中心与复选框对齐

<label class="inline-block">
<input class="ml-2 mr-1 mb-1 inline-block" data-id="{{inputDataId}}" type="checkbox" class="{{class}}" {% if required %} required {% endif %}>
<span class="text-sm inline-block">
  {{label}}
</span>
</label>

{{label}}
我只想让它看起来像这样: 顺风解决方案

使用尾翼,您应该会得到您想要的结果:

<label class="flex">
<input class="ml-2 mr-1 mb-1 mt-1 inline-block" data-id="{{inputDataId}}" type="checkbox" class="{{class}}" {% if required %} required {% endif %}>
<span class="text-sm inline-block">
 sdfsd fsd fsd fsdfds fsdf sdf s fsdfsdf
</span>
</label>

fsd fsd fsd fsd fsdfds fsdf sdf s fsdfsdf
自定义CSS解决方案:

<label class="flex">
<input class="ml-2 mr-1 mb-1 mt-1 inline-block" data-id="{{inputDataId}}" type="checkbox" class="{{class}}" {% if required %} required {% endif %}>
<span class="text-sm inline-block">
 sdfsd fsd fsd fsdfds fsdf sdf s fsdfsdf
</span>
</label>
通过使用flex positioning定位标签标签,您可以轻松地使用“align items:flex start;”对输入和文本进行垂直对齐:


{{label}}
.我的标签类{
显示器:flex;
调整项目:灵活启动;
}
Bootsrap解决方案

或者如果使用Boostrap,则可以用Boostrap类替换标签标记类:

 <label class="d-flex align-items-start">

然后,您的输入和文本将与顶部对齐


您可以使用“对齐项目中心”将它们居中对齐。

您需要将
flex items top
添加到包装器中,并删除输入的
mb-1


Dsfsd fsdfsdfs fsdfsd sdfsdfs sdfsdfs sdfsdfs sdf sdf sdf Dsfsd fsdfs fsdfs fsdfsd sdfsdfs
sdfsdfsdf sdf sdf dsfsd FSDFSDF
fsdfsdfsd sdfsdfs sdfsdfsf sdf sdf sdf dsfsd fsdfs fsdfsd sdfsdfs sdfsdfs sdfsdfs sdfsdfs sdfsdfs sdf sdf sdf

这使它看起来像我文章中的图像。我希望顶行居中于复选框。@Naomi您是否尝试过“对齐项目开始”而不是“对齐项目中心”?是的,但它会使标签低于复选框IM使用顺风而不是引导。好的,我只是用顺风示例编辑我的文章,该示例对您适用她希望文本和输入与顶部对齐。没有居中。