如何将文本移入按钮内,只有在我单击文本而不是单击按钮时才移动?参考。 (.button_text,.button_icon)

发布于 2025-02-13 06:23:34 字数 579 浏览 0 评论 0原文

.button__text {
    position:relative;
  
    transform:translate3d(0px, -4px, 0px);
    margin:0;
    align-self:end;
    grid-column:1/5;
    grid-row:2;

    text-align:center;
    font-size: 32px;
    font-weight:550;
    background-color: #aaaa;
    color: transparent;
    font-family: 'Nunito', sans-serif;
    
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
    transition: .13s ease-in-out;
}

.button__text:active {
    transform:translate3d(0px, 0px, 0px);
}
.button__text {
    position:relative;
  
    transform:translate3d(0px, -4px, 0px);
    margin:0;
    align-self:end;
    grid-column:1/5;
    grid-row:2;

    text-align:center;
    font-size: 32px;
    font-weight:550;
    background-color: #aaaa;
    color: transparent;
    font-family: 'Nunito', sans-serif;
    
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
    transition: .13s ease-in-out;
}

.button__text:active {
    transform:translate3d(0px, 0px, 0px);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笑百媚生 2025-02-20 06:23:34

您需要感觉到何时单击按钮,然后更改文本的翻译。

这是一个简单的片段 - 当按钮具有:活动时,其孩子会得到更改的定位。

.button__text {
  position: relative;
  transform: translate3d(0px, -4px, 0px);
  margin: 0;
  align-self: end;
  grid-column: 1/5;
  grid-row: 2;
  text-align: center;
  font-size: 32px;
  font-weight: 550;
  background-color: #aaaa;
  color: transparent;
  font-family: 'Nunito', sans-serif;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  background-clip: text;
  transition: .13s ease-in-out;
}

button:active .button__text {
  transform: translate3d(0px, 0px, 0px);
}
<button><div class="button__text">click me</div></button>

You need to sense when the button has been clicked and then alter the translation of the text.

Here's a simple snippet - when the button has :active then its child gets the altered positioning.

.button__text {
  position: relative;
  transform: translate3d(0px, -4px, 0px);
  margin: 0;
  align-self: end;
  grid-column: 1/5;
  grid-row: 2;
  text-align: center;
  font-size: 32px;
  font-weight: 550;
  background-color: #aaaa;
  color: transparent;
  font-family: 'Nunito', sans-serif;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  background-clip: text;
  transition: .13s ease-in-out;
}

button:active .button__text {
  transform: translate3d(0px, 0px, 0px);
}
<button><div class="button__text">click me</div></button>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文