【发布时间】:2020-05-23 22:28:24
【问题描述】:
你好,我想要一个组件(h3 或 div bg img) 悬停或聚焦 增加 h3 的亮度并将 box-shadow 应用于 bg img
我无法想象如何使用样式化的组件来做到这一点 我的代码:
<Styled.CardTop background={TestBG3}>
<div className="Bg" />
<div className="headerH3">
<h3>aaaaaaaaa.</h3>
</div>
</Styled.CardTop>
带有样式的 css:
const CardTop = styled.div`
position: relative;
height: 300px;
width: 100%;
margin-bottom:40px;
& .Bg {
display:flex;
align-items:center;
position:relative;
background-image: url(${({ background }) => background});
background-size: cover;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
height: 200px;
-o-background-size: cover;
background-size: cover;
background-position: center;
cursor:pointer;
:hover{
box-shadow: inset 0 0 100px 100px rgba(0, 0, 0, 0.1);
}
}
& .headerH3 {
padding: 0 10px;
display:flex;
align-items:center;
justify-content:center;
cursor:pointer;
color:#1976d2;
:hover,:active{
filter: brightness(115%);
}
}
【问题讨论】:
标签: css styled-components