相关疑难解决方法(0)

在线性渐变上使用背景位置的百分比值

有没有办法background-position取出百分比值?目前我的按钮仅适用于一个明确的价值观widthbackground-position.

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.button {
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  color: white;
  font-weight: bold;
  width: 350px;
  height: 50px;
  border: 1px solid green;
  transition: background 0.5s;
  background-repeat: no-repeat;
  background-image: linear-gradient(to left, #2484c6, #1995c8 51%, #00bbce), linear-gradient(to right, #2484c6 0%, #1995c8 51%, #00bbce 76%);
}
.button-pixel {
  background-position: -350px 0px, 0px 0px;
}
.button-pixel:hover {
  background-position: 0px 0px, 350px 0px;
}
.button-percentage …
Run Code Online (Sandbox Code Playgroud)

css background linear-gradients css3 background-position

12
推荐指数
1
解决办法
1634
查看次数

跨多行的伪元素创建连续的下划线动画

我在链接下有一条动画线。它适用于单行链接,但我有一些用换行符分隔的链接<br> 有没有办法让动画下划线沿着链接的所有行出现?谢谢

body {
  padding: 20px;
  font-family: Helvetica;
}

a {
  font-weight: bold;
  color: black;
  position: relative;
  text-decoration: none;
}

a::before {
  content: "";
  position: absolute;
  width: 0%;
  height: 2px;
  bottom: 0;
  background-color: #000;
  transition: all 0.2s;
}

a:hover::before {
  width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<a href="">my link</a>
<br><br>
<a href="">this is<br>a much<br>longer link</a>
Run Code Online (Sandbox Code Playgroud)

css pseudo-element css-animations

4
推荐指数
1
解决办法
1791
查看次数

从左到右悬停时加下划线

我正在探索 Tailwind,当我需要从左到右悬停时显示下划线时,我陷入了困境。

在普通 CSS 中,它会是这样

    .un {
      display: inline-block;
      padding-bottom:2px;
      background-image: linear-gradient(#000, #000);
      background-position: 0 100%; /*OR bottom left*/
      background-size: 0% 2px;
      background-repeat: no-repeat;
      transition:
        background-size 0.3s,
        background-position 0s 0.3s; /*change after the size immediately*/
    }
    
    .un:hover {
      background-position: 100% 100%; /*OR bottom right*/
      background-size: 100% 2px;
    }
Run Code Online (Sandbox Code Playgroud)
<span class="un">Underlined Text</span>
Run Code Online (Sandbox Code Playgroud)

但我不确定如何在 Tailwind 中应用这种转换。

tailwind-css

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