【发布时间】:2021-10-09 09:51:29
【问题描述】:
我使用 CSS 创建了类似的东西。
这里的棘手之处在于,如果文本太长,框的高度可能会发生变化。
所以,我不知道如何使虚线始终以这种方式运行,因为框的大小是动态的。
(从第一个框的中间到下一个框的中间应该总是有一条线)
这是我现在使用的 HTML 和 CSS。
-
我实际上在使用 SCSS 和 React(我正在打印“行”div 4 次)
<div class="wrapper"> <div class="row"> <div class="bordered-div"></div> <div class="step"> <img src="placeholder.svg" alt="img" /> <div class="step-text"> <div class="step-title">Title</div> <div class="step-description">Decsription...</div> </div> </div> </div> </div> .wrapper { display: flex; flex-direction: column; align-items: center; gap: 30px; .row { display: flex; position: relative; &:last-child { .bordered-div { height: 0; } } .bordered-div { position: absolute; top: 50%; left: -50px; width: 50px; border-top: 1px dashed #c2c9d5; border-left: 1px dashed #c2c9d5; height: calc(100% + 30px); } .step { background: blue; min-height: 118px; width: 322px; padding: 20px; border-radius: 8px; display: flex; gap: 20px; filter: drop-shadow(0px 0px 4px rgba(183, 183, 183, 0.15)) drop-shadow(0px 4px 4px rgba(217, 217, 217, 0.25)); svg { width: 16px; align-self: center; flex: none; } .step-title { font-size: 0.875rem; font-weight: 600; } .step-description { font-size: 0.875rem; } } } }
【问题讨论】: