当我悬停此Button组件时,它不会改变颜色。什么都没发生。当我在&:hover之前更改其他样式时,它就会更新。我也尝试过在css中这样做,但仍然不起作用。
import styled from "styled-components";
const Button = styled.button`
color: black;
padding: 15px 40px;
border-radius: 4px;
font-weight: normal;
text-transform: uppercase;
transition: all 0.2s ease-in-out;
margin: 1rem;
width: 40%;
&:hover {
color: rgba(255, 255, 255, 1);
box-shadow: 0 5px 15px rgba(145, 92, 182, 0.4);
}
`;
export default Button;
使用按钮的代码
import Images from "../components/slidingbackground";
import Button from "../components/HomeButton.styled";
const Home = () => {
return (
<div className="home-page-container">
<div className="home-text-container">
<h1 className="home-text-main">
Mobile <br /> Vehicle <br /> Verifier
</h1>
<div className="white-box">
<span className="underline">
<h2 id="verify-text">Verify Your Vehicle</h2>
</span>
<h3>With over 30 years of experience in Southern California,</h3>
<h4>I can inspect any non-salvaged vehicle, dealers welcome.</h4>
<div className="button-container">
<Button>Contact Me</Button>
</div>
</div>
</div>
<Images />
</div>
);
};
export default Home;
发布于 2021-08-28 16:58:40
事实证明它工作得很好,但是因为包含该按钮的div的z-index为-1,所以它没有发光。在scss样式中删除z-index:-1可以修复包含按钮的页面。
https://stackoverflow.com/questions/68968843
复制