css - 设计一个有序列表,其边框正好位于两个 li 元素的中间

标签 css list html-lists

我设计了以下列表。现在我想保留它的确切外观,但在 li 元素之间放置更多空间。不幸的是,使用“padding-bottom”它移动了 border-bottom,它不会准确地停留在两个元素之间的中间,而是粘在底部,正如它应该做的那样,我看到了。但我很乐意将它放在两个相邻的 li 元素的中间。现在我被困住了。我知道我可能会弄乱 html 源代码,但我宁愿保持它干净,只用 CSS 来做。谁能指出我有成果的地方?谢谢!

   <div id="list">
  <ul>
    <li><a href="#">No hacemos uso de cualquier de los componentes prefabricados o mezclas preparadas.</a></li>
    <li><a href="#">Una alta calidad en la compra de los ingredientes y la preparación es nuestra principal prioridad. </a></li>
    <li><a href="#">Todos nuestros productos se hacen con amor y se han inspirado en recetas familiares.</a></li>
    <li><a href="#">Punto tres</a></li>
    <li><a href="#">Queremos que nuestros clientes estén satisfechos. Si alguna vez tiene motivo de queja, le pedimos que nos devuelva su compra tan pronto como sea posible en nuestra tienda.</a></li>
  </ul>
</div>

    #list {
      width: 100%;
      margin: 30px;
      text-align:center;
    }

    #list ul {
      list-style-type: none;
      margin: 0;
      padding-bottom: 0;
    }

    #list ul li {
      font: 200 14px/1.5 'oswaldlight';
      border-bottom: 1px solid #ccc;
    }

    #list ul li:last-child {
      border: none;
    }

    #list li a {
      text-decoration: none;
      color: #000;
      text-align:center;

      -webkit-transition: font-size 0.3s ease, background-color 0.3s ease;
      -moz-transition: font-size 0.3s ease, background-color 0.3s ease;
      -o-transition: font-size 0.3s ease, background-color 0.3s ease;
      -ms-transition: font-size 0.3s ease, background-color 0.3s ease;
      transition: font-size 0.3s ease, background-color 0.3s ease;
      display: block;
      width: 100%;
    }

    #list li a:hover {
      font-size: 30px;
      background: #f6f6f6;
    }

最佳答案

您可以拆分 padding-toppadding-bottom 之间的值吗?

#list ul li {
    padding:2px 0;
}

这将在 li 元素的顶部和底部都有 2px 的填充,使边框保持在中间而不是粘在底部。

关于css - 设计一个有序列表,其边框正好位于两个 li 元素的中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24639063/

相关文章:

css - 如何定位标题,就好像它仍在表格内一样

CSS:左:0 或左:0px

c# 对自定义列表进行排序

css - IE img 不拉伸(stretch) li

html - 如何在元素中证明 li

css - 找不到 Pinax app.css

php - Bootstrap 移动菜单不显示在 wordpress 中

java - 我如何允许用户添加、编辑、删除列表组?如教室、小屋等

java - 收集 HashMap<String, List<String>> java 8

javascript - jQuery 加载多个 ul 列表的前 3 个元素