如何使用CSS设置图像之间的分隔线链接的样式?

Desired output:

Image 1

Actual result:

Image 1

结果与图中不同,两条线重叠.

这里是HTML/CSS,还有一个例子:

.divider {
  padding: 0px 180px;
}

.style-seven {
  border-bottom: 1px dashed #8c8c8c;
  border-left: 1px dashed #8c8c8c;
  border-bottom-left-radius: 20px;
  height: 100px;
  width: 85%;
}

.style-seven-2 {
  border-top: 1px dashed #8c8c8c;
  border-right: 1px dashed #8c8c8c;
  border-top-right-radius: 20px;
  height: 100px;
  width: 90%;
  transform: translateX(20px);
}
<div class="divider">
  <div class="style-seven"></div>
  <div class="style-seven-2"></div>
</div>

推荐答案

这可以只使用两个元素及其伪元素来完成.调整外部元素高度和水平边距以适应大小要求.

.divider {
  height: 100px; /* total divider height - could also be fluid */
  margin: 0 50px; /* spacing from parent element at sides */
  position: relative;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  height: calc(50% - .5px);  /* allow for half the border width */
  width: calc(50% - .5px);  /* allow for half the border width */
}

.divider::before {
  border-bottom: 1px dashed #8c8c8c;
  border-left: 1px dashed #8c8c8c;
  border-bottom-left-radius: 20px;
  top: 0;
  left: 0;
}

.divider::after {
  border-top: 1px dashed #8c8c8c;
  border-right: 1px dashed #8c8c8c;
  border-top-right-radius: 20px;
  right: 0;
  bottom: 0;
}

.divider-ends::before,
.divider-ends::after {
  content: '•';
  position: absolute;
  line-height: 0;
  color: #8c8c8c;
}

.divider-ends::before {
  top: 0;
  left: 0;
  transform: translateX(-50%); /* shift half of character width */
}

.divider-ends::after {
  bottom: 0;
  right: 0;
  transform: translateX(50%); /* shift half of character width */
}
<div class="divider">
  <div class="divider-ends">
</div>

Html相关问答推荐

为什么html复选框总是具有只读属性?

Font Awesome 6插入符号未显示

HTML表行悬停仅适用于偶数行

<;img>;和具有负边距的元素的堆叠顺序

首字下沉非字母字符

CURL邮箱中的图像不能调整其大小

对称渐变作为背景

背景可点击,而不是文本

使用Cypress循环遍历不一致的父对象

如何从elementor中的滑块中获取文本?

目标第一个祖先标签的 XPath

为什么我不能覆盖 div 的样式?

视频重新加载而不是在 Swift 中暂停 WKWebView

使用简单的 HTML 设计公司徽标和文本

并排对齐两个文本区域列

如何使用CSS Select 同级元素的::before伪元素?

如何让一个 div 元素粘在另一个元素上?

为四开本网站主页添加背景图片

悬停一个 div 时更改所有其他 div 上的字体 colored颜色

我怎么能有 :not(.class):nth-of-type(even)?