css: slides container display image
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 | <! doctype html> <!--[if lte IE 9]> <html class="ie" lang="en"> <![endif]--> <!--[if gt IE 9]><!--> < html lang="en"> <!--<![endif]--> < head > < meta charset="utf-8"> < title >geovindu: slides container display image</ title > < meta name="author" content="geovindu,Geovin Du"/> < link rel='stylesheet' href='css/ionicons.min.css'> < style > /*https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css https://onaircode.com/html-css-responsive-slider-examples/ */ $arrow: #3c376f; $bg: #fef8f9; * { box-sizing: border-box; &::before, &::after { box-sizing: border-box; } } body { margin: 0; background: $bg; } .container { max-width: 800px; margin: 0 auto; padding: 50px; } button { position: relative; display: inline-block; cursor: pointer; outline: none; border: 0; vertical-align: middle; text-decoration: none; background: transparent; padding: 20px 5px; color: $arrow; font-size: 2rem; } button span { position: relative; display: inline-block; transform: translateX(0); transition: transform 0.3s ease; } .previous:hover span { transform: translateX(-10px) scale(1.2); } .next:hover span { transform: translateX(10px) scale(1.2); } .slider-nav ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; } .slider-nav li { display: flex; flex: 2; text-align: center; } img { max-width: 100%; display: none; box-shadow: 10px 10px 20px 0 rgba(94,47,59,0.2); } img.active { display: block; animation: fadeImg 0.8s; } .slider-nav .arrow { flex: 0 0 15%; } .slider-nav a { flex-basis: 100%; display: flex; align-items: center; } .slider-nav span { display: block; width: 100%; } @keyframes fadeImg { from { opacity: 0; } to { opacity: 1; } } </ style > </ head > < body > < div class="container"> < div class="slider"> < img class="active" src="https://source.unsplash.com/gKk9rpyDryU"> < img src="https://source.unsplash.com/VFGEhLznjPU"> < img src="https://source.unsplash.com/InR-EhiO_js"> </ div > < nav class="slider-nav"> < ul > < li class="arrow"> < button class="previous"> < span > < i class="ion-arrow-left-c"></ i > </ span > </ button > </ li > < li class="arrow"> < button class="next"> < span > < i class="ion-arrow-right-c"></ i > </ span > </ button > </ li > </ ul > </ nav > </ div > < script language="javascript" type="text/javascript"> const items = document.querySelectorAll('img'); const itemCount = items.length; const nextItem = document.querySelector('.next'); const previousItem = document.querySelector('.previous'); let count = 0; function showNextItem() { items[count].classList.remove('active'); if(count < itemCount - 1) { count++; } else { count = 0; } items[count].classList.add('active'); console.log(count); } function showPreviousItem() { items[count].classList.remove('active'); if(count > 0) { count--; } else { count = itemCount - 1; } items[count].classList.add('active'); console.log(count); } function keyPress(e) { e = e || window.event; if (e.keyCode == '37') { showPreviousItem(); } else if (e.keyCode == '39') { showNextItem(); } } nextItem.addEventListener('click', showNextItem); previousItem.addEventListener('click', showPreviousItem); document.addEventListener('keydown', keyPress); </ script > </ body > </ html > |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2021-06-23 Easter 复活节(拉丁语:Pascha)