HTML+SCSS(CSS3) - 2021. 3. 20. 이미지 슬라이드 (Carousel) - 👍이미지 슬라이드 (Carousel) 안녕하세요 TriplexLab입니다. 오늘은 HTML + CSS3 만 가지고 이미지 슬라이드를 만들어 보겠습니다.이번에 구현하는 이미지 슬라이드는 IE 버전은 지원되지 않습니다. 참고하세요 <div class="slider"> <div class="slides"> <div id="slide-1"><img src="./img/1.png" alt=""></div> <div id="slide-2"><img src="./img/2.png" alt=""></div> <div id="slide-3"><img src="./img/3.png" alt=""></div> </div> <a href="#slide-1">1</a> <a href="#slide-2">2</a> <a href="#slide-3">3</a> </div> * { box-sizing: border-box; } .slider { width: 600px; text-align: center; border-radius: 10px; overflow: hidden; } .slides { display: flex; overflow-x: auto; /* overflow: hidden; */ scroll-snap-type: x mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; } .slides::-webkit-scrollbar { width: 10px; height: 10px; } .slides::-webkit-scrollbar-thumb { background: black; border-radius: 10px; } .slides::-webkit-scrollbar-track { background: transparent; } .slides > div { scroll-snap-align: start; flex-shrink: 0; width: 600px; height: 300px; margin-right: 50px; border-radius: 10px; overflow: hidden; background: #eee; transform-origin: center center; transform: scale(1); transition: transform 0.5s; position: relative; display: flex; justify-content: center; align-items: center; font-size: 100px; } .author-info { background: rgba(0, 0, 0, 0.75); color: white; padding: 0.75rem; text-align: center; position: absolute; bottom: 0; left: 0; width: 100%; margin: 0; } .author-info a { color: white; } img { object-fit: cover; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .slider > a { display: inline-flex; width: 1.5rem; height: 1.5rem; background: #eee; text-decoration: none; align-items: center; justify-content: center; border-radius: 50%; margin: 0 0 0.5rem 0; position: relative; } .slider > a:active { top: 1px; } .slider > a:focus { background: #000; } 잘 생각해보면 이제 IE 구형 브라우저를 지원해야 하는 프로젝트가 아닌 이상 굳이 slick, bxslider, swiper 이런 라이브러리 같은 거 사용할 필요가 없습니다. 괜히 사이트만 무거워져서 로딩 속도만 늦어집니다. Carousel.zip 5.80MB ✅참고자료 CSS-Only Carousel | CSS-Tricks It's kind of amazing how far HTML and CSS will take you when building a carousel/slideshow. Setting some boxes in a horizontal row with flexbox is easy. css-tricks.com 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기트리플랩 | TriplexLab 저작자표시 Contents 👍이미지슬라이드(Carousel) ✅참고자료 커피 한 잔 선물하기 당신이 좋아할만한 콘텐츠 미디어 쿼리 (Media Query) 와 Viewport 2021.05.23 유튜브(Youtube) 영상 비율에 마쳐 반응형으로 만들기 2021.05.15 퍼포먼스 사이드 메뉴 html+scss 2021.02.10 CSS 아이콘 라이브러리 fontello 사용하기 2020.12.27 댓글 0 + 이전 댓글 더보기