gpt4 book ai didi

html - 下拉组合框不对齐

转载 作者:行者123 更新时间:2023-11-28 02:55:43 25 4
gpt4 key购买 nike

参见:http://codepen.io/Chiz/pen/RaORwd

我在 Mac/Chrome 上。 2 个文本字段正确对齐但不是下拉框。有谁知道是什么原因造成的吗?

* {
font-family: "Open Sans";
}
form {
margin-top: 1%;
}
input {
width: 18rem;
height: 2rem;
border: 1px solid lighten(grey, 30%);
border-radius: 4px;
}
select {
width: 18rem;
height: 2.2rem;
}
input,
select {
margin-left: 6rem;
}
<form>
First Name:
<input type="text" name="firstname">
<br>
<br>Last Name:
<input type="text" name="lastname">
<br>
<br>Country:
<select>
<option value="Singapore">Singapore</option>
</select>
</form>

最佳答案

它们没有正确对齐,因为标签“Country:”比其他两个短。要解决此问题,您应该使用 position 属性而不是 margin-left。这将确保您将组件相对于页面而不是标签对齐。

这是一个使用 position:absolute 的简单示例:

*
{
font-family:"Open Sans";
}

form
{
margin-top:1%;
}

input
{
width:18rem;
height:2rem;
border:1px solid lighten(grey,30%);
border-radius:4px;
position: absolute;
left: 20%;
}

select
{
width:18rem;
height:2.2rem;
position: absolute;
left:20%;
}

关于html - 下拉组合框不对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37203242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com