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

gg0vcinb  于 2024-01-04  发布在  其他
关注(0)|答案(2)|浏览(216)

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

  1. #login-now {
  2. position: relative;
  3. font-size: 18px;
  4. color: white;
  5. background-color: #00a295;
  6. padding: 13px 94px 13px 94px;
  7. border-radius: 10px;
  8. line-height: 2.5;
  9. }
  10. #login-now-text {
  11. position: relative;
  12. z-index: 2;
  13. }
  14. #login-now:after{
  15. position: absolute;
  16. top: 0;
  17. left: 0;
  18. width: 0;
  19. height: 100%;
  20. content: "";
  21. border-radius: 10px;
  22. background-color: #007d73;
  23. transition: all .35s;
  24. }
  25. #login-now:hover:after{
  26. width: 100%;
  27. }

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

8iwquhpp

8iwquhpp1#

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

  1. #login-now {
  2. position: relative;
  3. font-size: 18px;
  4. color: white;
  5. background-color: #00a295;
  6. padding: 13px 94px 13px 94px;
  7. border-radius: 10px;
  8. line-height: 2.5;
  9. display: inline-block;
  10. overflow: hidden;
  11. }

字符串

vuktfyat

vuktfyat2#

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

  1. #login-now {
  2. position: relative;
  3. font-size: 18px;
  4. color: white;
  5. background-color: #00a295;
  6. padding: 13px 94px 13px 94px;
  7. border-radius: 10px;
  8. line-height: 2.5;
  9. clip-path: border-box;
  10. }
  11. #login-now-text {
  12. position: relative;
  13. z-index: 2;
  14. }
  15. #login-now:after {
  16. position: absolute;
  17. top: 0;
  18. left: 0;
  19. width: 0;
  20. height: 100%;
  21. content: "";
  22. border-radius: 10px;
  23. background-color: #007d73;
  24. transition: all .35s;
  25. }
  26. #login-now:hover:after {
  27. width: 100%;
  28. }

个字符

展开查看全部

相关问题