【CSS】鼠标进入图片流畅切换图片和显示变透明文字

1、切换图片

 
    .images {
        display: flex;
        justify-content: space-around;
    }

    .image-container {
        height: 500px;
        width: 800px;
        position: relative;
    }

    .image-container img {
        height: 100%;
        width: 100%;
        object-fit: cover;
    }

    .transition-image {
        position: absolute;
        top: 0px;
        left: 0px;
        opacity: 0;
        transition: opacity 0.5s ease;
    }

    .transition-image:hover {
        opacity: 1;
    }

 

【CSS】鼠标进入图片流畅切换图片和显示变透明文字_第1张图片

2、浮现黑色遮罩

    
    .images {
        display: flex;
        justify-content: space-around;
    }

    .fade::after {
        content: 'The mountains';
        color: white;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 30px;
        font-family: 'ZCOOL KuaiLe', cursive;
        background: black;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0px;
        right: 0px;
        opacity: 0;
    }

    .fade:hover::after {
        opacity: 0.5;
        transition: opacity 0.5s ease;
    }

 

【CSS】鼠标进入图片流畅切换图片和显示变透明文字_第2张图片

 

你可能感兴趣的:(CSS)