html - Div 不响应宽度 CSS

标签 html css width

在创建表单的过程中,我希望文本标签的宽度都相同。出于某种我无法辨别的原因,使用 width 无法正常工作:

.form-label {  display:inline; width: 160px; }

<div class="form-label required">First Name:</div>

Jsfiddle

如何让 .form-label 类响应宽度声明?谢谢!

最佳答案

将其从 display:inline 更改为 display:inline-block。

关于html - Div 不响应宽度 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16343927/

相关文章:

html - 悬停时返回颜色

javascript - 不用jquery模拟按键

php - (Wordpress) 不规则的 3-4-3-4 帖子结构

html - 如何将段落元素放入其父容器中?

宽度为 : 100% goes outside parent's bound 的 CSS 输入

css - 如何为动态下拉列表设置表格列宽?

css width % 工作不正常;比必要的时间更长

javascript - 为什么这段代码在 jsbin 中有效,但在 jsfiddle 中无效?

html - 那么下载的CSS文件存放在哪里呢?

html - Outlook 不遵守父表的宽度 ="600"