html - HTML -webkit-center 问题
问题描述
我写了一些代码,我意识到有一个问题。当我在 中使用-webkit-center
和写东西时textbox
,所有项目都向右移动。我尝试了其他-webkit
对齐设置,但没有问题,只是-webkit-center
. 我对此进行了研究,但找不到任何东西。谁能解释为什么?
这是您也可以尝试的代码。
<div id="mainDiv" style="text-align: -webkit-center; display: inline-grid; margin-left: 40%;border-style:double;">
<span>HEADER</span>
<input name="header" type="text" id="header" style="margin: 20px;width:173px;">
<span>CONTENT</span>
<input name="content" type="text" id="content" style="margin: 20px;height:50px;width:350px;">
<span>HEADER COLOR</span>
<input name="headColor" type="text" id="headColor" style="margin: 20px;width:173px;">
<span>CONTENT COLOR</span>
<input name="contColor" type="text" id="contColor" style="margin: 20px;width:173px;">
<input type="submit" name="button" value="SUBMIT" id="button" style="height: 30px;width:173px;margin:20px;">
</div>
解决方案
- webkit-center 属性的工作方式与普通的 text-center 属性不同。block 不是对齐内容,而是尝试对元素进行排序。
通过不同的造型,我得到了相同的外观。你可以控制它。对于每个输入,您需要键入媒体查询以响应,因为您提供了恒定的宽度值。
#mainDiv {
display: flex;
flex-direction: column;
align-items: center;
}
<div id="mainDiv" style=" text-align: center;width: 40%; margin:auto;border-style:double;">
<span>HEADER</span>
<input name="header" type="text" id="header" style="margin: 20px;width:173px;">
<span>CONTENT</span>
<input name="content" type="text" id="content" style="margin: 20px;height:50px;width:350px;">
<span>HEADER COLOR</span>
<input name="headColor" type="text" id="headColor" style="margin: 20px;width:173px;">
<span>CONTENT COLOR</span>
<input name="contColor" type="text" id="contColor" style="margin: 20px;width:173px;">
<input type="submit" name="button" value="SUBMIT" id="button" style="height: 30px;width:173px;margin:20px auto;">
</div>
推荐阅读
- java - 如果我在适配器类android的onbindView中循环
- r - 带有链接索引的嵌套 for 循环
- r - “哪个”函数没有在 R 中拾取元素
- spring-boot - 如何使用 Java prometheus sdk 创建带有标签的 Gauge 指标?
- linux - 如何通过 Linux Cron Job/Kubernetes cron 作业从 k8s 中删除被驱逐的 pod
- java - 使用 Spring Boot 为 Resilience4J 的断路器配置 Bean
- r - 栅格非 NA 像元计数
- java - Hiberante @JoinColumn
- javascript - 在 Typescript 中访问 Vue 数据对象
- python - Tensorflow Extended - 嵌套结构在训练期间断言失败