html 开始过渡对边界半径的影响

gg0vcinb  于 5个月前  发布在  其他
关注(0)|答案(2)|浏览(34)

我在一个元素上设置了一个过渡,但是效果开始于我设置的边界半径之外。
我希望效果从边框内开始。

#login-now {
    position: relative;
        font-size: 18px;
        color: white;
        background-color: #00a295;
        padding: 13px 94px 13px 94px;
        border-radius: 10px;
        line-height: 2.5;
}
#login-now-text {
    position: relative;
    z-index: 2;
}
#login-now:after{
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
        content: "";
        border-radius: 10px;
        background-color: #007d73;
        transition: all .35s;
}
#login-now:hover:after{
    width: 100%;
}

个字符
图像来源:https://imgur.com/a/LEv1kmb
我尝试添加ease-in并将top的值设置为另一个数字,但这对我不起作用。

8iwquhpp

8iwquhpp1#

你可以使用overflow:hidden来隐藏任何落在边界之外的福尔斯。但是你的<a>标签必须是一个块。然后你也可以在悬停效果上删除border-radius

#login-now {
  position: relative;
  font-size: 18px;
  color: white;
  background-color: #00a295;
  padding: 13px 94px 13px 94px;
  border-radius: 10px;
  line-height: 2.5;
  display: inline-block;
  overflow: hidden;
}

字符串

vuktfyat

vuktfyat2#

或者,您可以使用clip-path属性来裁剪按钮边框之外的所有内容。

#login-now {
  position: relative;
  font-size: 18px;
  color: white;
  background-color: #00a295;
  padding: 13px 94px 13px 94px;
  border-radius: 10px;
  line-height: 2.5;
  clip-path: border-box;
}

#login-now-text {
  position: relative;
  z-index: 2;
}

#login-now:after {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  content: "";
  border-radius: 10px;
  background-color: #007d73;
  transition: all .35s;
}

#login-now:hover:after {
  width: 100%;
}

个字符

相关问题