gpt4 book ai didi

css - 如何启动 te select 元素与表单中的标签对齐

转载 作者:行者123 更新时间:2023-11-27 23:10:01 25 4
gpt4 key购买 nike

.surveyform-class {
background: yellow;
margin: 0 25%;
width: 50%;
border-right: 40px solid yellow;
}
.main-div{
background: lightgrey;
width: 50%;
height:100%;
margin: 0 25%;
border-right: 20px solid yellow;
border-left: 20px solid yellow;
}
form {
/* Center the form on the page */
margin: 0 auto;
width: 400px;
}
form >div {
margin-top: 1em;
}
form >div >div {
padding-left: 95px;
}
label{
width: 90px;
text-align: right;
display: inline-block;

}
<DOCTYPE! html>
<html>
<head>
<title>Survey Form</title>
<link href="surveyform.css" type="text/css" rel="stylesheet">
</head>

<body>
<div style="
text-align: center;">

<h1 class="surveyform-class">Survey Form</h1>
<div class="main-div">
lwt us know how we can improve freecode camp
<form >
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="user_name">
</div>
<div>
<label for="mail">E-mail:</label>
<input type="email" id="mail" name="user_mail">
</div>
<div>
<label for="msg">Message:</label>
<textarea id="msg" name="user_message"></textarea>
</div>
<div >
<label>
which option best describes your current role
</label>

<select >
<option>student</option>
<option>engineer</option>
</select>
</div>
<div >
<label>
Things that should be improved in future
</label>


<input type="checkbox" name="a">
<span> Front end projects</span>

<div>

<input type="checkbox" name="a">
<span> Backend Projects</span>
</div>
<div>


<input type="checkbox" name="a">

<span> Structure </span>

</div>
</div>
</form>
</div>
</div>
</body>
</html>

我正在尝试对齐这些选择元素和标签以从同一行开始。

有人可以帮助我吗?

这是 jsfiddle 链接:http://jsfiddle.net/v650o2dL/2/

最佳答案

使用 css 属性 vertical-align:top。一定要像我下面做的那样把左右容器的容器分开;

.yellow {
background: yellow;
padding-left: 40px;
padding-right: 40px;
padding-bottom: 40px;
}

.yellow>h1 {
text-align: center;
}

.grey {
background: lightgrey;
height: 200px;
}

.row {
width: 100%;
display: block;
margin-bottom: 10px;
}

.left,
.right {
width: 49%;
display: inline-block;
vertical-align: top;
}

.input-group {
display: block;
margin-bottom: 10px;
}
<DOCTYPE! html>
<html>

<head>
<title>Survey Form</title>
<link href="surveyform.css" type="text/css" rel="stylesheet">
</head>

<body>

<div class="yellow">
<h1>Survey Form</h1>

<div class="grey">

<center>
Let us know how we can improve freecode camp
</center>

<br>

<form>
<div class="row">
<div class="left">
<label>
Which option best describes your current role
</label>
</div>

<div class="right">
<select>
<option>student</option>
<option>engineer</option>
</select>
</div>
</div>

<div class="row">
<div class="left">
<label>
Things that should be improved in future
</label>
</div>

<div class="right">

<div class="input-group">
<input type="checkbox" name="a">
<span> Front end projects</span>
</div>

<div class="input-group">
<input type="checkbox" name="a">
<span> Backend Projects</span>
</div>

<div class="input-group">
<input type="checkbox" name="a">
<span> Structure </span>
</div>
</div>
</div>

</form>
</div>
</div>
</body>

</html>

关于css - 如何启动 te select 元素与表单中的标签对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58580213/

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