html - 类别/子类别列表的 CSS 样式

标签 html css

.parent {
  position: relative;
}

.parent .parent-header:after {
  content: '';
  position: absolute;
  width: 1px;
  height: 30px;
  left: 15px;
  top: 36px;
  border-left: 1px dotted black;
}

.child {
  padding-left: 30px;
  position: relative;
}

.child .child-header:before {
  content: '';
  position: absolute;
  width: 1px;
  height: 100%;
  left: 15px;
  top: 0px;
  border-left: 1px dotted black;
}

.child:last-child .child-header:before {
  content: none;
}

.child .child-header:after {
  content: '';
  height: 1px;
  width: 15px;
  position: absolute;
  left: 15px;
  top: 15px;
  border-top: 1px dotted black;
}
<div class="parent">
  <h2 class="parent-header">Heading</h2>
  <div class="child">
    <h2 class="child-header">Block 1</h2>
    <div>some text some text some text some text some text some text some text some text some text some text some text some tex</div>
  </div>
  <div class="child">
    <h2 class="child-header">Block 2</h2>
    <div>some text some text some text some text some text some text some text some text some text some text some text some tex</div>
  </div>
  <div class="child">
    <h2 class="child-header">Block 3</h2>
    <div>some text some text some text some text some text some text some text some text some text some text some text some tex</div>
  </div>
</div>

http://plnkr.co/edit/LmA1wsn8pLPwQCtPnqtM?p=preview

请查看 plnkr。我试图填补垂直线之间的差距。有人能帮我吗。我愿意接受比我为实现该样式所做的更好的方法

最佳答案

http://plnkr.co/edit/H7LTMEBRlOpm89nCMCl6?p=preview

这是你需要的东西。

.parent .parent-header:after {
  top: 35px;
}

.child-header {
  margin-top:0;
  padding-top:25px;
}

.child:last-child .child-header:before {
  height: 35px;
}

基本上造成这种差距的是 h2.child-header 的边距。因此,您需要将其更改为填充,然后只需修改 .child-header:after top 值即可。

希望我能帮到你。

关于html - 类别/子类别列表的 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43748902/

相关文章:

php - 我正在用 PHP 生成一个 word 文档,如何进行分页?

javascript - 有没有一种可靠的方法来为浏览器中播放的音频文件计时 javascript 动画?

html - 如何拉伸(stretch) SVG 形状的图像以填充其边界?

javascript - jQuery 选项卡和 shift+tab 显示导航

使用媒体查询后 HTML 被禁用

html - Center Child 动态 div

javascript - 如何在不影响其余页面样式的情况下加载带样式的 HTML 文件?

javascript - 尝试让 stylize() 使用 CSS 样式分别随机选择单元格 bgcolor 和文本样式

html - <span> 中可以有 <span> 吗?

javascript - header 元素未对齐