Html 如何将两段文字排列/对齐到方框中
可能重复: 我要写两段:Html 如何将两段文字排列/对齐到方框中,html,css,Html,Css,可能重复: 我要写两段: Para 1 Para 2 如何使其看起来像: Para1 Para2 都在各自的空间和盒子里 <div> <div class="block" id="profile"> <h3>Professional Profile</h3> <p>Knowledge in all aspects of web application development. My Skills to
Para 1
Para 2
如何使其看起来像:
Para1 Para2
都在各自的空间和盒子里
<div>
<div class="block" id="profile">
<h3>Professional Profile</h3>
<p>Knowledge in all aspects of web application development.
My Skills to solve programming errors gets the job
faster. Proficient in performance tuning database applications.</p>
</div>
我在这里干什么
<div class="block" id ="contact">
<p>
<h3> Contact</h3>
<address>Written by W3Schools.com<br /><a href="mailto:rjohn5854@howardcc.edu">
Email Me!!!</a><br />Address: Box 3223,City<br />Phone:6750</address>
<p>
</div>
</div>
CSS
div.block p {
display: inline-block;
}
使用或类似:
p { display: inline-block; }
在HTML段落中,tag是block元素,所以它占据了父元素的所有宽度。如果可以在一行中排列两个块,则需要将块行为更改为内联。对其使用display:inline或display:inline块。在css中:
.align-profile,
.align-contact
{
display: inline-block;
vertical-align: top; //also can try other align settings
width: 45%;
}
.align-contact
{
margin-left: 30px; //also try depending on the spacing you want between them
}
在html中:
<div class="align-profile">
<h2>Profile</h2>
para1
</div>
<div class="align-contact">
<h2>Contact</h2>
para2
</div>
注:div或段落必须对齐才能实现此目的。如果你把div放在div里,或者把段落放在段落里,那是行不通的。你试过什么?说真的,伙计,你认为免费的自由职业者董事会也是这样吗?伙计,冷静。。。。我附上了一张到目前为止我所拥有的图片。很多人做XD,有些人只是对VS和制作网站非常陌生,不知道如何学习其他东西。人们习惯于yahoo答案,我猜:/没错,我确实搜索了一个重复的答案..找不到任何,所以我打开这个问题。将您的类从div.block p更改为just.block,它应该会修复它。您在实现建议的更改时遇到问题吗?