-
Notifications
You must be signed in to change notification settings - Fork 35
[HTML, CSS, JS] 아마존 - 네비게이션UI 미션 제출합니다. #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
10008c8
cbe9654
b481dd1
38aa4e7
6ba14ed
9c1d78d
4a2b895
6046298
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,13 @@ | ||
| # javascript-amazon | ||
| 레벨3 | ||
| # 아마존 사이트 Card UI Clone Coding | ||
|
|
||
| ## 기획서 | ||
|
|
||
|  | ||
|
|
||
| ## HTML 설계도 | ||
|
|
||
|  | ||
|
|
||
| ## 구현 기능 | ||
|
|
||
| - ㅇ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| @charset 'utf-8'; | ||
|
|
||
| /* reset */ | ||
| * { | ||
| box-sizing: border-box; | ||
| font-family: Apple SD Gothic Neo, Malgun Gothic, sans-serif; | ||
| } | ||
|
|
||
| html, body, div, span, applet, object, iframe, | ||
| h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
| a, abbr, acronym, address, big, cite, code, | ||
| del, dfn, em, img, ins, kbd, q, s, samp, | ||
| small, strike, strong, sub, sup, tt, var, | ||
| b, u, i, center, | ||
| dl, dt, dd, ol, ul, li, | ||
| fieldset, form, label, legend, | ||
| table, caption, tbody, tfoot, thead, tr, th, td, | ||
| article, aside, canvas, details, embed, | ||
| figure, figcaption, footer, header, hgroup, | ||
| menu, nav, output, ruby, section, summary, | ||
| time, mark, audio, video{ | ||
| margin: 0; | ||
| padding: 0; | ||
| border: 0; | ||
| font-size: 100%; | ||
| vertical-align: baseline; | ||
| } | ||
|
|
||
| /* HTML5 display-role reset for older browsers */ | ||
| article, aside, details, figcaption, figure, | ||
| footedestination_wrar, header, hgroup, menu, nav, section { | ||
| display: block; | ||
| } | ||
|
|
||
| body { | ||
| line-height: 1; | ||
| } | ||
| ol, ul { | ||
| list-style: none; | ||
| } | ||
|
|
||
| blockquote, q { | ||
| quotes: none; | ||
| } | ||
|
|
||
| blockquote:before, blockquote:after, | ||
| q:before, q:after { | ||
| content: ''; | ||
| content: none; | ||
| } | ||
|
|
||
| table { | ||
| border-collapse: collapse; | ||
| border-spacing: 0; | ||
| } | ||
| button { | ||
| border: none 0; | ||
| background: transparent; | ||
| outline: none 0; | ||
| } | ||
|
|
||
| input:focus, | ||
| select:focus, | ||
| button:focus { | ||
| outline: none; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| .clearfix:after { | ||
| display: block; | ||
| clear: both; | ||
| content: ""; | ||
| } | ||
|
|
||
| .br { | ||
| display: block; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .wrap { | ||
| position: relative; | ||
| margin: 30px 70px; | ||
| } | ||
|
|
||
| .slide-container { | ||
| padding: 20px; | ||
| margin: 0 auto; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .slide-navigation li { | ||
| float: left; | ||
| width: 25%; | ||
| } | ||
|
|
||
| .slider { | ||
| width: calc(100% * 4); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calc이런함수 사용좋네요. |
||
| } | ||
|
|
||
| .slider > li { | ||
| overflow: hidden; | ||
| padding: 20px 20px; | ||
| float: left; | ||
| width: calc(100% / 4); | ||
| } | ||
|
|
||
| .slider li .img-wrap, | ||
| .slider li .contents-wrap { | ||
| float: left; | ||
| } | ||
|
|
||
| .slider li .img-wrap { | ||
| width: 30%; | ||
| } | ||
|
|
||
| .slider li .img-wrap img { | ||
| width: 100%; | ||
| height: auto; | ||
| display: block; | ||
| border-radius: 1000px; | ||
| } | ||
|
|
||
| .slider li .contents-wrap { | ||
| width: calc(100% - 30%); | ||
| padding-left: 20px; | ||
| } | ||
|
|
||
| .contents-wrap > h2 { | ||
| font-size: 28px; | ||
| line-height: 32px; | ||
| font-weight: 300; | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| .contents-wrap > ul > li { | ||
| font-size: 18px; | ||
| line-height: 28px; | ||
| font-weight: 300; | ||
| } | ||
|
|
||
| .slide-container { | ||
| overflow: hidden; | ||
| position: relative; | ||
| } | ||
|
|
||
| .slide-navigation { | ||
| margin-left: -5px; | ||
| margin-right: -5px; | ||
| } | ||
|
|
||
| .slide-navigation li { | ||
| padding: 0 5px; | ||
| height: 60px; | ||
| transition: 0.2s ease-in; | ||
| } | ||
|
|
||
| .slide-navigation li:hover, | ||
| .slide-navigation li button:hover { | ||
| cursor: pointer; | ||
| transform: scale(1.1); | ||
| transition: 0.2s ease-in; | ||
| } | ||
|
|
||
| .slide-navigation li:first-child button { | ||
| background-color: blue; | ||
| } | ||
|
|
||
| .slide-navigation li:nth-child(2) button { | ||
| background-color: purple; | ||
| } | ||
|
|
||
| .slide-navigation li:nth-child(3) button { | ||
| background-color: green; | ||
| } | ||
|
|
||
| .slide-navigation li:last-child button { | ||
| background-color: orange; | ||
| } | ||
|
|
||
| .slide-navigation li button { | ||
| color: #fff; | ||
| width: 100%; | ||
| height: 100%; | ||
| display: block; | ||
| /* align-items: center; */ | ||
| /* justify-content: space-around; */ | ||
| } | ||
|
|
||
| .slide-btn { | ||
| position: absolute; | ||
| width: 100%; | ||
| height: 40px; | ||
| /* height: 100%; */ | ||
| top: 50%; | ||
| left: 50%; | ||
| transform: translate(-50%, -50%); | ||
| } | ||
|
|
||
| .slide-btn button { | ||
| position: absolute; | ||
| height: 100%; | ||
| width: 40px; | ||
| background-image: url(../images/button.png); | ||
| background-size: 100%; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .slide-btn .prev-btn { | ||
| left: -30px; | ||
| } | ||
|
|
||
| .slide-btn .next-btn { | ||
| right: -30px; | ||
| transform: rotate(180deg); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ko"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link rel="stylesheet" href="css/reset.css"> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <script type="text/javascript" src="js/index.js"></script> | ||
| <title>아마존</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="wrap"> | ||
| <div class="slide-container"> | ||
| <ul class="slide-navigation clearfix"> | ||
| <li> | ||
| <button type="button">Fast, free Delivery</button> | ||
| </li> | ||
| <li> | ||
| <button type="button"><span class="br">Exclusive deals and </span>offers</button> | ||
| </li> | ||
| <li> | ||
| <button type="button"><span class="br">Prime Originals,</span> <span class="br">movies and TV</span> <span class="br">shows<span></button> | ||
| </li> | ||
| <li> | ||
| <button type="button"><span class="br">Over 2 million songs </span>ad free</button> | ||
| </li> | ||
| </ul> | ||
| <ul class="slider clearfix"> | ||
| <li> | ||
| <div class="img-wrap"> | ||
| <img src="images/1.png" alt="귀여운 이미지"> | ||
| </div> | ||
| <div class="contents-wrap"> | ||
| <h2>Prime Originals, exclusively on Prime Video</h2> | ||
| <ul> | ||
| <li>Save on groceries and get an additional 10% off</li> | ||
| <li>Save 20% off diapers, baby food, and more</li> | ||
| <li>Prime Video is the only place</li> | ||
| <li>Prime Video is the only place</li> | ||
| </ul> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| <div class="img-wrap"> | ||
| <img src="images/2.png" alt="귀여운 이미지"> | ||
| </div> | ||
| <div class="contents-wrap"> | ||
| <h2>Enjoy exclusive savings and rewards</h2> | ||
| <ul> | ||
| <li>Save on groceries and get an additional 10% off</li> | ||
| <li>Save 20% off diapers, baby food, and more</li> | ||
| <li>Prime Video is the only place</li> | ||
| <li>Prime Video is the only place</li> | ||
| </ul> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| <div class="img-wrap"> | ||
| <img src="images/3.jpg" alt="귀여운 이미지"> | ||
| </div> | ||
| <div class="contents-wrap"> | ||
| <h2>Prime Originals, exclusively on Prime Video</h2> | ||
| <ul> | ||
| <li>Save on groceries and get an additional 10% off</li> | ||
| <li>Save 20% off diapers, baby food, and more</li> | ||
| <li>Prime Video is the only place</li> | ||
| <li>Prime Video is the only place</li> | ||
| </ul> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| <div class="img-wrap"> | ||
| <img src="images/4.jpg" alt="귀여운 이미지"> | ||
| </div> | ||
| <div class="contents-wrap"> | ||
| <h2>Prime Originals, exclusively on Prime Video</h2> | ||
| <ul> | ||
| <li>Save on groceries and get an additional 10% off</li> | ||
| <li>Save 20% off diapers, baby food, and more</li> | ||
| <li>Prime Video is the only place</li> | ||
| <li>Prime Video is the only place</li> | ||
| </ul> | ||
| </div> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| <div class="slide-btn"> | ||
| <button type="button" class="prev-btn"></button> | ||
| <button type="button" class="next-btn"></button> | ||
| </div> | ||
| </div> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| class AmazonCarousel { | ||
| constructor(option) { | ||
| this.slides = option.slides; | ||
| this.currentIndex = option.currentIndex; | ||
| this.maxIndex = option.maxIndex; | ||
| this.prev = option.prev; | ||
| this.next = option.next; | ||
| this.nav = option.nav; | ||
| console.log(this.nav); | ||
| } | ||
|
|
||
| moveSlides() { | ||
| let translate = "translateX(" + -100 * this.currentIndex + "%)"; | ||
| this.slides.forEach(element => { | ||
| console.log(element); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 디버깅은 debugger; 입력도 있을테고, 그것보다 개발자도구의 breakpoint를 찍어서 하는게 더 편리할거에요. |
||
| element.style.transform = translate; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. transform이 다른 속성대비 장점이 뭔지 오늘 수업때 언급했는데요. |
||
| }); | ||
| } | ||
|
|
||
| onClickHandler() { | ||
| this.prev.addEventListener("click", () => { | ||
| this.currentIndex--; | ||
| if (this.currentIndex < 0) { | ||
| this.currentIndex = this.maxIndex - 1; | ||
| } | ||
| this.moveSlides(); | ||
| }); | ||
|
|
||
| this.next.addEventListener("click", () => { | ||
| this.currentIndex++; | ||
| if (this.currentIndex > this.maxIndex - 1) { | ||
| this.currentIndex = 0; | ||
| } | ||
| this.moveSlides(); | ||
| }); | ||
|
|
||
| this.nav.forEach((el, index) => { | ||
| el.addEventListener("click", () => { | ||
| this.currentIndex = index; | ||
| this.moveSlides(); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| window.addEventListener("DOMContentLoaded", () => { | ||
| const carouselChildren = document.querySelectorAll(".slider > li"); | ||
| const buttonPrev = document.querySelector(".prev-btn"); | ||
| const buttonNext = document.querySelector(".next-btn"); | ||
| const buttonNav = document.querySelectorAll(".slide-navigation > li"); | ||
| let current = 0; | ||
| let total = 4; | ||
|
|
||
| const startMove = new AmazonCarousel({ | ||
| slides: carouselChildren, | ||
| currentIndex: current, | ||
| maxIndex: total, | ||
| prev: buttonPrev, | ||
| next: buttonNext, | ||
| nav: buttonNav | ||
| }); | ||
|
|
||
| startMove.onClickHandler(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 이렇게 별도 메서드를 불러서 핸들러 등록을 할 수도 있긴해요 constructor() { |
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
br이건 태그명과 같아서 잘 안쓰는 이름같네요.