• 分享一个图像轮播效果


    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站

    话不多说,先看效果:
    在这里插入图片描述
    根据图片的播放,页面背景会被替换为当前图片。
    在这里插入图片描述
    老规矩,源码自己拿:

    DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Titletitle>
        <script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js">script>
        <script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js">script>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
    
            body {
                height: 100vh;
                display: grid;
                place-items: center;
                overflow: hidden;
            }
    
            main {
                position: relative;
                width: 100%;
                height: 100%;
                box-shadow: 0 3px 10px rgba(0,0,0,0.3);
            }
    
            .item {
                width: 200px;
                height: 300px;
                list-style-type: none;
                position: absolute;
                top: 50%;
                transform: translateY(-50%);
                z-index: 1;
                background-position: center;
                background-size: cover;
                border-radius: 20px;
                box-shadow: 0 20px 30px rgba(255,255,255,0.3) inset;
                transition: transform 0.1s, left 0.75s, top 0.75s, width 0.75s, height 0.75s;
    
            &:nth-child(1), &:nth-child(2) {
                                 left: 0;
                                 top: 0;
                                 width: 100%;
                                 height: 100%;
                                 transform: none;
                                 border-radius: 0;
                                 box-shadow: none;
                                 opacity: 1;
                             }
    
            &:nth-child(3) { left: 50%; }
            &:nth-child(4) { left: calc(50% + 220px); }
            &:nth-child(5) { left: calc(50% + 440px); }
            &:nth-child(6) { left: calc(50% + 660px); opacity: 0; }
            }
    
            .content {
                width: min(30vw,400px);
                position: absolute;
                top: 50%;
                left: 3rem;
                transform: translateY(-50%);
                font: 400 0.85rem helvetica,sans-serif;
                color: white;
                text-shadow: 0 3px 8px rgba(0,0,0,0.5);
                opacity: 0;
                display: none;
    
            & .title {
                  font-family: 'arial-black';
                  text-transform: uppercase;
              }
    
            & .description {
                  line-height: 1.7;
                  margin: 1rem 0 1.5rem;
                  font-size: 0.8rem;
              }
    
            & button {
                  width: fit-content;
                  background-color: rgba(0,0,0,0.1);
                  color: white;
                  border: 2px solid white;
                  border-radius: 0.25rem;
                  padding: 0.75rem;
                  cursor: pointer;
              }
            }
    
            .item:nth-of-type(2) .content {
                display: block;
                animation: show 0.75s ease-in-out 0.3s forwards;
            }
    
            @keyframes show {
                0% {
                    filter: blur(5px);
                    transform: translateY(calc(-50% + 75px));
                }
                100% {
                    opacity: 1;
                    filter: blur(0);
                }
            }
    
            .nav {
                position: absolute;
                bottom: 2rem;
                left: 50%;
                transform: translateX(-50%);
                z-index: 5;
                user-select: none;
    
            & .btn {
                  background-color: rgba(255,255,255,0.5);
                  color: rgba(0,0,0,0.7);
                  border: 2px solid rgba(0,0,0,0.6);
                  margin: 0 0.25rem;
                  padding: 0.75rem;
                  border-radius: 50%;
                  cursor: pointer;
    
            &:hover {
                 background-color: rgba(255,255,255,0.3);
             }
            }
            }
    
            @media (width > 650px) and (width < 900px) {
                .content {
            & .title        { font-size: 1rem; }
            & .description  { font-size: 0.7rem; }
            & button        { font-size: 0.7rem; }
            }
            .item {
                width: 160px;
                height: 270px;
    
            &:nth-child(3) { left: 50%; }
            &:nth-child(4) { left: calc(50% + 170px); }
            &:nth-child(5) { left: calc(50% + 340px); }
            &:nth-child(6) { left: calc(50% + 510px); opacity: 0; }
            }
            }
    
            @media (width < 650px) {
                .content {
            & .title        { font-size: 0.9rem; }
            & .description  { font-size: 0.65rem; }
            & button        { font-size: 0.7rem; }
            }
            .item {
                width: 130px;
                height: 220px;
    
            &:nth-child(3) { left: 50%; }
            &:nth-child(4) { left: calc(50% + 140px); }
            &:nth-child(5) { left: calc(50% + 280px); }
            &:nth-child(6) { left: calc(50% + 420px); opacity: 0; }
            }
            }
        style>
    head>
    <body>
    <main>
        <ul class='slider'>
            <li class='item' style="background-image: url('https://cdn.mos.cms.futurecdn.net/dP3N4qnEZ4tCTCLq59iysd.jpg')">
                <div class='content'>
                    <h2 class='title'>"Lossless Youths"h2>
                    <p class='description'> Lorem ipsum, dolor sit amet consectetur
                        adipisicing elit. Tempore fuga voluptatum, iure corporis inventore
                        praesentium nisi. Id laboriosam ipsam enim.  p>
                    <button>Read Morebutton>
                div>
            li>
            <li class='item' style="background-image: url('https://i.redd.it/tc0aqpv92pn21.jpg')">
                <div class='content'>
                    <h2 class='title'>"Estrange Bond"h2>
                    <p class='description'> Lorem ipsum, dolor sit amet consectetur
                        adipisicing elit. Tempore fuga voluptatum, iure corporis inventore
                        praesentium nisi. Id laboriosam ipsam enim.  p>
                    <button>Read Morebutton>
                div>
            li>
            <li class='item' style="background-image: url('https://wharferj.files.wordpress.com/2015/11/bio_north.jpg')">
                <div class='content'>
                    <h2 class='title'>"The Gate Keeper"h2>
                    <p class='description'> Lorem ipsum, dolor sit amet consectetur
                        adipisicing elit. Tempore fuga voluptatum, iure corporis inventore
                        praesentium nisi. Id laboriosam ipsam enim.  p>
                    <button>Read Morebutton>
                div>
            li>
            <li class='item' style="background-image: url('https://images7.alphacoders.com/878/878663.jpg')">
                <div class='content'>
                    <h2 class='title'>"Last Trace Of Us"h2>
                    <p class='description'>
                        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tempore fuga voluptatum, iure corporis inventore praesentium nisi. Id laboriosam ipsam enim.
                    p>
                    <button>Read Morebutton>
                div>
            li>
            <li class='item' style="background-image: url('https://theawesomer.com/photos/2017/07/simon_stalenhag_the_electric_state_6.jpg')">
                <div class='content'>
                    <h2 class='title'>"Urban Decay"h2>
                    <p class='description'>
                        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tempore fuga voluptatum, iure corporis inventore praesentium nisi. Id laboriosam ipsam enim.
                    p>
                    <button>Read Morebutton>
                div>
            li>
            <li class='item' style="background-image: url('https://da.se/app/uploads/2015/09/simon-december1994.jpg')">
                <div class='content'>
                    <h2 class='title'>"The Migration"h2>
                    <p class='description'> Lorem ipsum, dolor sit amet consectetur
                        adipisicing elit. Tempore fuga voluptatum, iure corporis inventore
                        praesentium nisi. Id laboriosam ipsam enim.  p>
                    <button>Read Morebutton>
                div>
            li>
        ul>
        <nav class='nav'>
            <ion-icon class='btn prev' name="arrow-back-outline">ion-icon>
            <ion-icon class='btn next' name="arrow-forward-outline">ion-icon>
        nav>
    main>
    body>
    <script>
        const slider = document.querySelector('.slider');
        function activate(e) {
            const items = document.querySelectorAll('.item');
            e.target.matches('.next') && slider.append(items[0])
            e.target.matches('.prev') && slider.prepend(items[items.length-1]);
        }
    
        document.addEventListener('click',activate,false);
    script>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
  • 相关阅读:
    数字货币--暗池
    在使用了spring-cloud-starter-gateway后,为什么还会发生cors问题
    Android统一管理Timer计时器Service工具
    花费-效益分析筛选肿瘤标记物最佳组合
    基于微信共享充电桩小程序毕业设计作品成品(3)开发技术文档_充电桩小程序前端技术栈
    USB Composite 组合设备之耳机+多路CDC
    STM32G070RBT6基于Arduino框架GPIO外部中断
    vue 内置指令-v-pre/v-memo
    了解低压差稳压IC(LDO)及其在电池驱动设备中的意义
    在Docker里安装FastDFS分布式文件系统详细步骤
  • 原文地址:https://blog.csdn.net/qq_35241329/article/details/134445235