html - 如何将两个输入文本字段移动到同一行?
问题描述
我正在设计我的第一个网站,并且正在尝试制作一个人们可以填写表格的标签。我有两个名字和姓氏的输入字段,但它们位于不同的行上。
我想将它们并排移动到上面的行,在灰色框旁边。基本上我想让所有东西都在同一条线上。下面是 HTML 和 CSS:
.Contact-Us h1 {
text-align: center;
padding-bottom: 20px;
padding-top: 10px;
}
#Start-registration {
display: flex;
border: 1px solid grey;
background-color: #DCDCDC;
margin-left: 30px;
width: 170px;
}
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<article class="Contact-Us">
<h1> Contact Us </h1>
<p class="Subtitle-Info"> Contact us via sending a message </p>
<p id="Start-registration"> First and last name </p>
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name" />
</form>
<form action="" method="get" class="Last-name">
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name" />
</form>
</article>
解决方案
你应该只有一个这样的表格..
.Contact-Us h1 {
text-align: center;
padding-bottom: 20px;
padding-top: 10px;
}
#Start-registration {
display: flex;
border: 1px solid grey;
background-color: #DCDCDC;
margin-left: 30px;
width: 170px;
}
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'/>
<title>SerFin</title>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@300&display=swap" rel="stylesheet">
<link href='../test.css' rel='stylesheet'/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$('.dropdown').hover(function(){
$('.dropdown-menu', this).stop(true, true).slideDown(0);
$(this).addClass('open');
},
function(){
$('.dropdown-menu', this).stop(true, true).slideUp(0);
$(this).removeClass('open');
});
});
</script>
</head>
<body>
<header>
<nav>
<ul class="menu">
<li><a href="../SerFin.html">Home</a></li>
<li><a href='Customer-service.html'>Customer Service</a></li>
<li><a href="Info.html">About us</a><li>
<li><a href='#'>Submission</a></li>
<li class="dropdown">
<a class="dropdown-toggle" href="#">Search Engine <b class="caret"></b><a>
<ul class="dropdown-menu">
<li><a href="#">Universities</a></li>
<li><a href="#">Jobs</a></li>
<li><a href="#">Courses</a></li>
<li><a href="#">Internships</a></li>
<li><a href="#">Services</a></li>
</ul>
</li>
</ul>
<ul class="setup">
<li><a href='#'>Login</a></li>
<li><a href="#">Sign up</a></li>
</ul>
</nav>
</header>
<article class="Contact-Us">
<h1> Contact Us </h1>
<p class="Subtitle-Info"> Contact us via sending a message </p>
<p id="Start-registration"> First and last name </p>
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name"/>
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name"/>
</form>
</article>
</body>
</html>
推荐阅读
- cocoahttpserver - CocoaHTTPServer 是否支持流式响应?
- mysql - 如何让查询包含来自另一个表的名称及其名称的 id
- java - 当一个线程死了它的对象会发生什么?
- python - KeyError: 'input_1_ib-0' 当我保存我的自动编码器模型时
- openedge - 如何以 30 分钟为间隔对 24 小时数据进行分组以获取计数?
- javascript - React:重新加载页面后不再获取数据
- jquery - 平滑滚动偏移在 iOS Safari 上不起作用
- python - 递归查找最后一位数字总和
- ringcentral - RingCentral 选择扩展用户并将他们从应用程序中注销
- php - 带有 API 的 ERC20 交易列表