banner
meanc

meanc

自部署博客在 blog.meanc.cc
twitter
github
discord server

Learn a few CSS tricks from others

Using one element's hover to trigger another element's animation#

.banner:has(.product:hover) .rock img:nth-child(3){
    transform: translateX(100px) translateY(100px);
}

mask-image#

Image overlay mask-image can create a can effect

image

mask-image overlay gradient creates a gradually transparent effect on both sides#

image

    mask-image: linear-gradient(
        to right,
        transparent,
        #000 10% 90%,
        transparent
    );

Infinite looping animation, adding delay can create an infinite scrolling effect

.slider .list .item{
    width: var(--width);
    height: var(--height);
    position: absolute;
    left: 100%;
    animation: autoRun 10s linear infinite;
    transition: filter 0.5s;
    animation-delay: calc( (10s / var(--quantity)) * (var(--position) - 1) )!important;
}

By adding hover effects to both parent and child elements, create a selection effect

.slider:hover .item{
    animation-play-state: paused!important;
    filter: grayscale(1);
}
.slider .item:hover{
    filter: grayscale(0);
}

Flexibly using CSS variables can make animations easier to create#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.