【发布时间】:2015-05-05 21:36:54
【问题描述】:
我想要 3 个文本框沿水平轴左、中、右对齐,并且在同一行上。
我可以使用margin-left和margin-right在中间设置一个文本框,然后使用position:absolute和left:0我可以在左侧获得一个文本框(在同一行作为中间框)。
现在的问题是最后一个盒子,右边的盒子。使用position:absolute 和right:0,将框定位在右侧,但在下方显示一行。
我不知道我做错了什么,老实说,我不知道position:absolute 和left:0 是如何使元素与中间元素出现在同一行的。
#sectionM,
#sectionL,
#sectionR {
width: 250px;
border: 1px outset black;
padding: 5%;
text-align: center;
}
#sectionM {
margin-left: auto;
margin-right: auto;
}
#sectionL {
position: absolute;
left: 0px;
}
#sectionR {
position: absolute;
right: 0px;
}
header {
text-align: center;
}
nav {
text-align: center;
}
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Misha's Homepage</title>
<link rel="stylesheet" type="text/css" href="mainstyle.css">
</head>
<header>
<h1>Hi!</h1>
</header>
<nav><a href="archive/myFirstWebpage/mainPage.html">Archive</a>
</nav>
<article>
<section id="sectionL">
This is the left LEFT.
</section>
<section id="sectionM">
This is the mid MID.
</section>
<section id="sectionR">
This is the right RIGHT.
</section>
</article>
</html>
【问题讨论】: