【发布时间】:2019-06-07 16:21:12
【问题描述】:
我正在尝试将我的输入部分与 div 的中心对齐,标签左对齐在输入的左侧。我似乎无法让输入部分在 div 的中心彼此对齐。请耐心等待,我对任何类型的编码都非常陌生,所以我的代码可能不是最好的。 到目前为止,这是我的 html 和 css: 这就是我希望它看起来的样子。标签在左侧,输入字段在中间。 IMG
.othercomponent {
background-color: white;
height: 30px;
border-radius: 10px;
width: 95%;
margin: 0 auto;
margin-top: 10px;
text-indent: 10px;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: medium;
font-weight: bold;
display: block;
}
.lpks-input {
width: 35%;
display: inline-block;
padding-right: 5px;
}
<body class="body">
<div class="othercomponent">Plot Name <input class="lpks-input"></div>
<div class="othercomponent">Other Name <input class="lpks-input"></div>
</body>
这是一个 JSFiddle 来展示我现在所拥有的: https://jsfiddle.net/h8vo2opv/
【问题讨论】:
-
能发一张想要的效果图吗?
-
所以你想要div左边的文本和中间的inputfield?
-
我会尽快发布一张图片。没错,斯特凡。我想要左边的文本和中间的输入字段。
-
我更新了我的答案和你的图片不一样。但是标签在左边,文本框在中间。