Как нарисовать адаптивные линии с точками, которые на картинке снизу.
Я бы мог скинуть пример моего кода, но я понятия не имею как рисовать такие сложные линии =(
2 ответа
div {
width: 80%;
margin: auto;
height: 6em;
display: grid;
grid-template: 1fr 1fr / 1fr 1fr;
margin-bottom: -1px;
}
div::before {
content: "";
grid-row: 1;
grid-column: 1;
border: 1px solid;
border-color: transparent transparent blue blue;
border-bottom-left-radius: 2em;
}
div::after {
content: "";
grid-row: 2;
grid-column: 2;
margin-top: -1px;
border: 1px solid;
border-color: blue blue transparent transparent;
border-top-right-radius: 2em;
}
<div></div>
Вариант с точками:
div {
outline: 1px dotted silver;
width: 80%;
margin: auto;
height: 6em;
display: grid;
grid-template: 1fr 1fr / 1fr 1fr;
padding: 1em;
padding-bottom: calc(1em - 1px);
background:
radial-gradient(circle at 1em 1em, red .5em, transparent calc(.5em + 1px)),
radial-gradient(circle at calc(100% - 1em) calc(100% - 1em), red .5em, transparent calc(.5em + 1px));
}
div::before, div::after {
content: "";
border: 1px solid;
z-index: -1;
}
div::before {
grid-row: 1;
grid-column: 1;
border-color: transparent transparent blue blue;
border-bottom-left-radius: 2em;
}
div::after {
grid-row: 2;
grid-column: 2;
margin-top: -1px;
border-color: blue blue transparent transparent;
border-top-right-radius: 2em;
}
<div></div>
-
@Хлебушек, кладём внутрь div и через position: absolute. Ну или вообще добавить этой штуке padding и сделать через radial-gradient.– Qwertiy ♦19 фев в 13:42
-
-
-
-
Все три линии адаптивные, к тому же есть параметры завязанные не CSS переменных.
Но если количество блоков и\или вид линий будет изменятся - то придётся всё переделывать.
/* Основные стили блок */
.block {
display: flex;
justify-content: center;
width: 100%;
--line-weight: 2px;
--line-color: #999;
--line-radius: 10px;
--line-dot-size: 16px;
}
.item {
width: calc(100% / 3);
}
.item:nth-child(1) {--accent-color: #18adb4;}
.item:nth-child(2) {--accent-color: #1685a3; margin: 0 20px;}
.item:nth-child(3) {--accent-color: #275469;}
.card {
display: block;
width: 100%;
border-radius: 30px;
background-color: var(--accent-color);
box-shadow: 10px 10px 10px 0 rgba(0,0,0,.2);
}
/* когда .card будет заполняться, правило ниже нужно будет убрать. */
.card::before {
content: '';
display: block;
width: 100%;
height: 0;
padding: 50%;
}
.line-block {
width: 100%;
min-height: 80px;
margin-top: 20px;
position: relative;
}
.line {
border: 0 solid var(--line-color);
position: absolute;
margin-top: calc(var(--line-dot-size) / 2);
}
.line::before,
.item:nth-child(2) .line::after {
content: '';
display: block;
width: var(--line-dot-size);
height: var(--line-dot-size);
border-radius: 50%;
background-color: var(--accent-color);
position: absolute;
transform: translate(-50%, -50%);
}
.item:nth-child(1) .line,
.item:nth-child(3) .line {
height: calc(50% - (var(--line-weight) / 2 + var(--line-dot-size) / 2));
}
/* LINE 1 */
.item:nth-child(1) .line:nth-child(1) {
width: 50%;
border-radius: 0 0 0 var(--line-radius);
border-left-width: var(--line-weight);
border-bottom-width: var(--line-weight);
left: 50%;
margin-left: calc(var(--line-weight) * -.5);
}
.item:nth-child(1) .line:nth-child(1)::before {
margin-left: calc(var(--line-weight) * -.5);
}
.item:nth-child(1) .line:nth-child(2) {
width: 40%;
border-radius: 0 var(--line-radius) 0 0;
border-right-width: var(--line-weight);
border-top-width: var(--line-weight);
top: calc(50% - (var(--line-weight) / 2 + var(--line-dot-size) / 2));
left: 100%;
margin-left: calc(var(--line-weight) * -.5);
}
.item:nth-child(1) .line:nth-child(2)::before {
left: calc(100% + var(--line-weight) / 2);
top: 100%;
}
/* LINE 2 */
.item:nth-child(2) .line {
width: var(--line-weight);
height: calc(100% - var(--line-dot-size));
border-radius: 0;
border: 0;
background-color: var(--line-color);
left: 50%;
transform: translateX(-50%);
}
.item:nth-child(2) .line::before,
.item:nth-child(2) .line::after {
left: 50%;
margin-left: var(--line-weight * -.5);
}
.item:nth-child(2) .line::after {
top: 100%;
margin-top: 0;
}
/* LINE 3 */
.item:nth-child(3) .line:nth-child(1) {
width: 50%;
border-radius: 0 0 var(--line-radius) 0;
border-right-width: var(--line-weight);
border-bottom-width: var(--line-weight);
right: calc(50% - var(--line-weight) / 2);
}
.item:nth-child(3) .line:nth-child(1)::before {
left: calc(100% + var(--line-weight) / 2);
}
.item:nth-child(3) .line:nth-child(2) {
width: 40%;
border-radius: var(--line-radius) 0 0 0;
border-left-width: var(--line-weight);
border-top-width: var(--line-weight);
top: calc(50% - (var(--line-weight) / 2 + var(--line-dot-size) / 2));
right: calc(100% - var(--line-weight) / 2);
}
.item:nth-child(3) .line:nth-child(2)::before {
left: 0;
top: 100%;
margin-left: calc(var(--line-weight) * -.5);
}
/* Для демо */
body {
width: 100%;
min-height: 100vh;
overflow: hidden;
margin: 0;
padding: 5px;
box-sizing: border-box;
}
.resize {
display: block;
min-width: 100px;
width: 100%;
max-width: 100%;
min-height: 125px;
height: auto;
max-height: 100vh;
background-color: rgba(0,0,0,.05);
box-shadow: 0 0 0 1px rgba(255,0,0,.5);
overflow: hidden;
resize: both;
}
.block,
.item,
.line-block {
height: 100%;
}
.item {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
height: 100%;
}
<div class="resize">
<!-- Основная разметка блока -->
<div class="block">
<div class="item">
<div class="card"></div>
<div class="line-block">
<div class="line"></div>
<div class="line"></div>
</div>
</div>
<div class="item">
<div class="card"></div>
<div class="line-block">
<div class="line"></div>
</div>
</div>
<div class="item">
<div class="card"></div>
<div class="line-block">
<div class="line"></div>
<div class="line"></div>
</div>
</div>
</div>
<!-- ----------------------- -->
</div>
P.S. Смотреть открыв сниппет на весь экран.