小编use*_*719的帖子

CSS 点领导者位于复杂背景的第一行

我需要使用 CSS 在第一行文本之后实现点引导符,以便在纹理/图像背景上使用它。

预期行为:

在此输入图像描述

我在互联网上看到了一些点领导者的实现。他们都使用以下技术之一:

  1. ::点+溢出之后
<div class=item1>
  <span class=text1>
    Text
  </span>
  <span class=price1>
    $100
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)
<div class=item1>
  <span class=text1>
    Text
  </span>
  <span class=price1>
    $100
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)
  1. 绝对点+白色背景
<div class=item2>
  <span class=text2>
    <span class=bg2>
      Text
    </span>
  </span>
  <span class=price2>
    <span class=bg2>
      $100
    </span>
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)
.item1 {
  display: flex;
}
.text1 {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}
.text1::after {
  content: '';
  position: absolute;
  bottom: 0;
  border-bottom: 1px dotted grey;
  width: 100%;
}
.price1 {
  align-self: flex-end;
} …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

17
推荐指数
1
解决办法
672
查看次数

标签 统计

css ×1

flexbox ×1

html ×1