我想在下面制作标签列表 我想使用CSS而不是使用Table标签 我怎么能这样做?
Tags: Apple Banana Melon Strawberry Kiwi Orange
Pineapple Carrot Onion Tomato Bacon Sandwitch
SoyBeans Pork Beef Chicken
答案 0 :(得分:3)
使用display:table-cell
<强> HTML 强>
<div class="table">
<div class="td">tags</div>
<div class="td">Apple Banana Melon Strawberry Kiwi Orange Pineapple Carrot Onion Tomato Bacon Sandwitch SoyBeans Pork Beef Chicken </div>
</div>
<强> CSS 强>
.table{display:table-row; width:350px; }
.td:first-child{width:10px; }
.td{display:table-cell; padding:10px; width:320px}
<强> LIVE DEMO 强>
答案 1 :(得分:1)
你可以这样做:
HTML:
<div class="left">
Tags:
</div>
<div class="right">
Apple Banana Melon Strawberry Kiwi Orange
Pineapple Carrot Onion Tomato Bacon
Sandwitch SoyBeans Pork Beef Chicken
</div>
CSS:
.left, .right
{
color:#2B91AF;
}
.left
{
float: left;
width: 30px; //adjust this width according to your needs
margin-right: 10px; //adjust this margin according to your needs
}
.right
{
float: left;
width: 400px; //adjust this width according to your needs
}
这是一个小提琴,因为它很好: http://jsfiddle.net/VQjGW/
答案 2 :(得分:0)
对于这样的事情,我建议使用定义列表。你可以在这里阅读一篇很棒的文章:http://css-tricks.com/utilizing-the-underused-but-semantically-awesome-definition-list/
之后,使用css和定位元素应该很容易,就像在你的例子中一样