【发布时间】:2014-01-05 12:34:52
【问题描述】:
请问如何使用 css3 水平对齐 div 标签的两个内容。我的封闭主体的总宽度为 950 像素,我将第一个 div 标签的宽度指定为 470 像素。我的假设是第二个 div 标签将占据 480 像素的剩余空间,但它在定位时没有占据
这是html代码
<div class="left colborder">
<p>To know what's cooking you can check our <a href="#"> events </a> for more
<br />For more information Contact Us</p>
<div class="left-ContactInformation">
<img src="Picture%20Related/Email%20Logo.png" alt="Email Address Icon" title="Email Address Icon" id="EmailAddressIcon" />j.banti09@gmail.com
<br />
<img src="Picture%20Related/Telephone%20Logo.png" alt="Phone Number Icon" title="Phone Number Icon" id="PhoneNumberIcon" />08138549501</div>
</div>
<!--There Should be a separator (vertical)-->
<form action="/" method="post">
<div class="right">Tell us what you think or feel about this site
<div id="right-UserComment">
<input type="text" name="Name" placeholder="Name" required />
<input type="email" name="Email" placeholder="Email Address" required />
<br />
<textarea cols="40" rows="3" wrap="hard" required placeholder="What's up?" name="comments"></textarea>
</div>
<button type="submit" value="submit">Send</button>
</div>
</form>
这是CSS,它包括容器、左右div标签css。
container{
width:950px;
margin:0;
margin-left:auto;
margin-right:auto;
border-style:solid;
background-color:orange;
}
.left {
width:450px;
margin-left:10px;
}
.right{
width:390px;
margin-left:10px;
}
【问题讨论】:
-
我们可以在这里看到你的 CSS 吗?我猜您从未将 .left 和 .right 设置为浮动或内联,因此它们被设置为块。
-
您可能会发现这很有帮助 -- stackoverflow.com/questions/2935404/…