以下 ul 是左对齐的,我试图将其置于 #category_list div 的中心,但我似乎无法正确处理。
我认为问题在于 ul 没有环绕其内容,而是扩展到全宽。
我在这里想念什么?
谢谢你的帮助。
<html>
<head>
<style>
#category_list {
padding: 1em 0 2em;
text-align:center;
border: 1px solid red;
}
#category_list ul{
padding: 0;
display:inline-block;
text-align: left;
border: 1px solid red;
margin: 0 auto;
}
#category_list li{
display:inline-block;
width: 13.75em;
padding: 1em 0;
margin: 0 .5em 1em;
border-bottom: 1px solid #aaaaaa;
}
#category_list h2{
text-align: left;
margin: 0;
font: 1em "Georgia", Serif;
font-style: italic;
}
</style>
</head>
<body>
<div id="category_list">
<ul>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
<li><h2>Title</h2><img src="_images/categories/img.jpg"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></li>
</ul>
</div>
</body>
</html>