根据最适合相关内容的内容选择您的标记。如果您有表格数据,那么它属于表格。列表应该放在列表中。不要基于一些“tagX 不好”的想法或因为它看起来是一种特定的方式而选择,因为外观可以改变。最终,任何东西都可以看起来像其他任何东西,所以只需选择合适的基础。
表格不是我对此类内容的首选标记,但可以接受。
http://jsfiddle.net/dcWsp/
table, tbody {
display: block;
}
tr {
display: block;
overflow: hidden;
margin: 1em 0;
}
td {
display: block;
}
td.avatar {
float: left;
margin-right: 1em;
}
td.author {
font-weight: bold;
}
<table>
<!-- loop starts here -->
<tr>
<td class="avatar"><img src="http://placehold.it/100x100" /></td>
<td class="author">Batman</td>
<td class="message">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porta elit vel ante hendrerit facilisis. Curabitur aliquam sollicitudin diam, id posuere elit consectetur nec. Vestibulum quam dolor, feugiat in posuere a, posuere imperdiet tellus. Mauris sed ligula vitae urna consequat aliquet.</td>
</tr>
<!-- loop ends here -->
</table>
这是另一种标记和样式的方法,看起来几乎相同:
http://jsfiddle.net/dcWsp/2/
article {
overflow: hidden;
margin: 1em 0;
}
img.avatar {
float: left;
margin: 0 1em 1em 0;
}
h1.author {
font-weight: bold;
}
<section class="comments">
<!-- loop starts here -->
<article>
<h1 class="author"><img src="http://placehold.it/100x100" class="avatar" /> Batman</h1>
<p class="message">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porta elit vel ante hendrerit facilisis. Curabitur aliquam sollicitudin diam, id posuere elit consectetur nec. Vestibulum quam dolor, feugiat in posuere a, posuere imperdiet tellus. Mauris sed ligula vitae urna consequat aliquet.</p>
</article>
<!-- loop ends here -->
</section>