html - 居中无序列表

标签 html css

有一个 h2 居中的图像,并希望它下面的列表也居中。现在已经挣扎了一个多小时,但似乎没有任何进展。有什么建议吗?

.images {
  display: inline-block;
  text-align: center;
  width: 33%;
  /* all ements align to the largest element within the div */
  vertical-align: top;
}

.images ol {
  width: 70%;
}

.images ol li {
  line-height: 1.2em;
  border: 0;
}
<div class="images">
  <h3>Panacotta Vanilla</h3>
  <img src="photo1.png.png">
  <p>recipe ingridients</p>
  <ol>
    <li>Macro free Ranged Chicken</li>
    <li>Cover chicken in almond meal</li>
    <li>Add cayenne pepper, chilli flakes, mixed herbs and paprika</li>
    <li>Cook until all pink of chicken disappears Salad
    </li>

  </ol>
</div>

最佳答案

在整个页面 View 中运行此操作以获得最佳效果。

.images{
    display:inline-block;
    text-align:center;
    width:33%;
    /* all ements align to the largest element within the div */
    vertical-align:top;

   
}

.images ol{
    margin-left:auto;width:100%;margin-right:auto;
}
.images ol li{
  text-align:left;
  margin-left:15%;margin-right:20%;
  line-height:1.2em;
  border:0;

}

   
   
<div class = "images">
		<h3>Panacotta Vanilla</h3>
				<img src = "photo1.png.png">
				<p>recipe ingridients</p>
				<ol id="mylist">
					<li>Macro free Ranged Chicken</li>
					<li>Cover chicken in almond meal</li>
					<li>Add cayenne pepper, chilli flakes, mixed herbs and paprika</li>
					<li>Cook until all pink of chicken disappears 
					Salad</li>

				</ol>
		</div>

关于html - 居中无序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44937047/

相关文章:

html - 使用绝对定位和溢出在边界框之外创建元素

html - 让名字很好地出现在同一行

html - 如何在一个 div 中仅将一个 div 居中,其余的保持原样

html - 自定义 Bootstrap 对话框

javascript - 在保持默认样式的同时禁用按钮集

html - 在单个 UL 中左右分隔列表项

javascript - 错误函数中的 JQuery AJAX HTML 响应

javascript - 使用 jQuery 滚动时如何为每个 anchor 设置不同的偏移量

html - 如何在 Ubuntu 上的 VS Code 中格式化 HTML 代码?

php isset 中的非法偏移类型或为空