提问人:Ramesh Madara 提问时间:4/25/2023 更新时间:4/25/2023 访问量:32
Pointer-events :有选择地启用和禁用。CSS的
Pointer-events : Enable and Disable selectively. CSS
问:
在下面的Next.js组件中,我只想向.itemCard和按钮添加悬停效果。这两者必须具有不同的悬停效果。 (ex- itemcard 将具有框阴影效果,并且按钮将具有背景颜色变化)。 我尝试过 pinter-events:没有以各种方式进行,但没有运气。
const Img = (props: imgProps) => {
return (
<div className={styles.itemCard}>
<div className={styles.imagecontainer}>
<div className={styles.imageOuter}>
<img className={styles.imageItself} src={props.img} alt="" />
</div>
<div className={styles.details}>
<h3 className={styles.titleCardHome}>{props.title}</h3>
<p className={styles.description}>Lorem ipsum dolor sit amet consectetur.</p>
<p className={styles.priceHome}>{props.price}</p>
<button className={styles.btncartAdd}>Add to Cart</button>
</div>
</div>
</div>
);
};
这是我卡顿的CSS:
.itemCard {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
max-width: 20rem;
min-width: 15rem;
background-color: rgba(255, 255, 255, 0);
border-radius: 5px;
margin: 10px;
transition: .3s;
transition: transform 0.3s ease-in-out;
}
.imagecontainer {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
max-width: 20rem;
min-width: 15rem;
background-color: rgb(234, 202, 117);
border-radius: 5px;
margin: 20px;
transition: .3s;
transition: transform 0.3s ease-in-out;
box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.139);
}
.imagecontainer .imageOuter {
max-height: 60%;
min-height: 60%;
width: 100%;
background-color: antiquewhite;
}
.imagecontainer .imageOuter img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 5px 5px 0px 0px;
pointer-events: none;
}
.itemCard :not(.btncartAdd):hover{
transition: transform 0.3s ease-in-out;
/* transform: scale(1.01); */
transition: .3s;
box-shadow: 0px 10px 17px rgba(0, 0, 0, 0.214);
}
.details :not(.btncartAdd) {
pointer-events: none;
}
.itemCard
.details {
font-family: 'Courier New', Courier, monospace;
display: flex;
flex-direction: column;
margin: -50px 5px -30px 5px;
background-color: rgb(254, 229, 160);
box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.067);
width: 100%;
height: 8rem;
border-radius: 5px;
padding: 10px;
}
.details .btncartAdd {
background-color: rgb(223, 84, 20);
border: none;
width: 100%;
padding: 5px;
margin-top: 10px;
color: white;
border-radius: 5px;
}
如何实现这一点?
答: 暂无答案
评论
:hover
CSS 伪类呢?