想要在ReactJS中的Button上发光效果

问题描述 投票:0回答:1

在这里,我想要在按钮上有发光效果。我已经完成了基本的,但需要一些现代的光泽效果。我想在悬停后进入该按钮,那么如何制作更真实、更高级的发光效果呢?你能给一些建议吗?代码如下。

import "./styles.css";
import HomeIcon from "@mui/icons-material/Home";
export default function App() {
  return (
    <div className="App">
      <div class="container">
        <div class="nav shine">
          <div class="inner-icon ">
            <HomeIcon />
          </div>
          <p class="inner-text">Home</p>
        </div>
      </div>
    </div>
  );
}

css代码在下面

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: lightgray;
}

.nav {
  width: 70px;
  background: gray;
  padding: 0px 0px 10px 0px;
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
  height: 50px;
  transition: 0.5s;
}
.nav:hover::before {
  content: "";
  position: absolute;
  background-color:  rgba(255, 255, 255, 0.5);
  left: 0px;
  top: 0px;
  height: 100%;
  width: 20px;
  animation: shine 2s infinite linear;
}
@keyframes shine {
  0% {
    left: 0px;
    opacity: 0;
    transform: translateX(0px) skewX(-15deg);
  }
  100% {
    left: 100px;
    opacity: 1;
    transform: translateX(5px) skewX(-15deg);
  }
}
.inner-text {
  position: absolute;
  bottom: -10px;
  opacity: 1;
  transition: 0.5s;
}

.nav:hover .inner-text {
  transform: translate(50px, -10px);
}
.nav:hover {
  padding: 0px 60px 0px 0px;
}
css animation css-animations effects
1个回答
0
投票

我总是这样使用某物:

.shine {
  -webkit-mask-image: linear-gradient(
    -75deg,
    rgba(0, 0, 0, 1) 30%,
    rgba(0, 0, 0, 0.93) 50%,
    rgba(0, 0, 0, 1) 70%
  );
  -webkit-mask-size: 200%;
  animation: shine 2s linear infinite;
}
  
@keyframes shine {
  from {
    -webkit-mask-position: 150%;
  }
  to {
    -webkit-mask-position: -50%;
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.