Displaying paragraphs in table style without tables
Quick question about some CSS. I've had this page that was coded with tables and I would now like to transition it to CSS. The table has pictures and contact info for a list of people, so it was put in a 2x2 table (there are four people). Now there are four paragraphs filled with the information that I need, I just need to lay them out in the correct order. Currently they are all of the same class, 开发者_StackOverflow中文版would it help to add ids to all of them?
Add them to a <div class="container">
container, and give the <p>
-tags the following styles:
div.container p {
width:50%;
float:left;
}
Hope this helps.
No, it's perfectly alright if they have the same class. Let's say they have the class myblock
.
.myblock {
width:50%;
padding:0;
margin:0;
float:left;
}
.myblock img {
float:left;
padding-right:10px;
}
Then this code would just put two of those blocks next to each other, two per row.
<div class="myblock">
<!-- The paragraph -->
<img src="people/photo.jpg"/>
Name<br/>
Position<br/>
Tel. 123 12345-314
</div>
Try this...
p {
display: table-cell
}
Edit: What is the correct order? Can you post some code or layout examples?
精彩评论