CONTENTS
홈페이지 만들기
<html>
<css>
<js>
1)dropdown
2)slider
3)tab
-----------------------------------------------------------------
홈페이지 만들기
예제)
<html>
<body>
<!-- header start -->
<header class="header_top">
<div id="header_top" class="container">
<div>
<p>Free shipping for standard order over $100</p>
</div>
<div class="header_right">
<div><a href="#">Help & FAQs</a></div>
<div><a href="#">My Account</a></div>
<div><a href="#">EN</a></div>
<div><a href="#">USD</a></div>
</div>
</div>
</header>
<!-- header end -->
<!-- nav start -->
<nav id="nav">
<div class=" navline container">
<div class="nav_left">
<ul class="main_menu">
<li class="menuList_Home"><a href="#">Home</a>
<ul class="sub_menu display_none">
<li><a href="#">Homepage 1</a></li>
<li><a href="#">Homepage 2</a></li>
<li><a href="#">Homepage 3</a></li>
</ul>
</li>
<li><a href="#">Shop</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="nav_icon">
<div><i class="fa-solid fa-magnifying-glass"></i></div>
<div><i class="fa-solid fa-cart-shopping"></i></div>
<div><i class="fa-regular fa-heart"></i></div>
</div>
</div>
</nav>
<!-- nav end -->
<!-- section slider start-->
<section id="slider">
<div class="slidebox">
<div class="slides">
<div class="slide">
<!-- 컨텐츠 1, 2, 3 -->
<div class="textbox">
<h3>Women Collection 2018</h3>
<h2>NEW SEASON</h2>
<a href="#">Shop Now</a>
</div>
<div><img src="images/slide-01.jpg" alt="slide-01"></div>
</div>
<div class="slide">
<div class="textbox">
<h3>Men New-Season</h3>
<h2>Jackets & Coats</h2>
<a href="#">Shop Now</a>
</div>
<div><img src="images/slide-02.jpg" alt="slide-01"></div>
</div>
<div class="slide">
<div class="textbox">
<h3>Men Collection 2018</h3>
<h2>New arrivals</h2>
<a href="#">Shop Now</a>
</div>
<div><img src="images/slide-03.jpg" alt="slide-01"></div>
</div>
</div>
</div>
<div class="controlbox">
<div><i class="fa-solid fa-caret-left left"></i></div>
<div><i class="fa-solid fa-caret-right right"></i></div>
</div>
</section>
<!-- slider end -->
<!-- banner start -->
<section id="banner" class="container">
<div class="banner bb1">
<div class="banner_textbox b1">
<h2>Women</h2>
<span>spring 2018</span>
<div class="hover_banner">
<a href="#">Shop Now</a>
</div>
</div>
<div class="banner_imgbox">
<img src="images/banner-01.jpg" alt="">
</div>
</div>
<div class="banner bb2">
<div class="banner_textbox b2">
<h2>Men</h2>
<span>spring 2018</span>
<div class="hover_banner"><a href="#">Shop Now</a></div>
</div>
<div class="banner_imgbox">
<img src="images/banner-02.jpg" alt="">
</div>
</div>
<div class="banner bb3">
<div class="banner_textbox b3">
<h2>Accessories</h2>
<span>New Trend</span>
<div class="hover_banner"><a href="#">Shop Now</a></div>
</div>
<div class="banner_imgbox">
<img src="images/banner-03.jpg" alt="">
</div>
</div>
</section>
<section id="product" class="container">
<div>
<h2>Product Overview</h2>
</div>
<div class="product_list">
<div id="tab_box">
<ul id="tab_button">
<li class="tab" id="a">All Products</li>
<li class="tab" id="b">Women</li>
<li class="tab" id="c">Men</li>
<li class="tab" id="d">Bag</li>
<li class="tab" id="e">Shoes</li>
<li class="tab" id="f">Watches</li>
</ul>
</div>
<div class="product_icon">
<div>
<i class="fa-solid fa-filter"></i>
<span>Filter</span>
</div>
<div>
<i class="fa-solid fa-magnifying-glass"></i>
<span>Search</span>
</div>
</div>
</div>
<div id="tab_content" class="cardbox">
<!-- All products1 -->
<div class="product_card a">
<div><img src="images/product-01.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Esprit Ruffle Shirt</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$16.64</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-02.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$35.31</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-03.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Only Check Trouser</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$25.50</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-04.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Classic Trench Coat</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$75.00</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-05.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Front Pocket Jumper</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$34.75</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-06.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Vintage Inspired Classic</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$93.20</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-07.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Shirt in Stretch Cotton</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$52.66</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-08.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Pieces Metallic Printed</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$18.96</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-09.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Converse All Star Hi Plimsolls</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$75.00</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-10.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Femme T-Shirt In Stripe</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$25.85</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-11.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$63.16</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-12.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$63.15</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-13.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>T-Shirt with Sleeve</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$18.49</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-14.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Pretty Little Thing</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$54.79</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-15.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Mini Silver Mesh Watch</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$86.85</span>
</div>
</div>
<div class="product_card a">
<div><img src="images/product-16.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Square Neck Back</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$29.64</span>
</div>
</div>
<!-- Women -->
<div class="product_card b">
<div><img src="images/product-01.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Esprit Ruffle Shirt</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$16.64</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-02.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$35.31</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-04.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Classic Trench Coat</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$75.00</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-05.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Front Pocket Jumper</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$34.75</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-07.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Shirt in Stretch Cotton</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$52.66</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-08.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Pieces Metallic Printed</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$18.96</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-10.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Femme T-Shirt In Stripe</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$25.85</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-13.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>T-Shirt with Sleeve</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$18.49</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-14.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Pretty Little Thing</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$54.79</span>
</div>
</div>
<div class="product_card b">
<div><img src="images/product-16.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Square Neck Back</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$29.64</span>
</div>
</div>
<!-- Men -->
<div class="product_card c">
<div><img src="images/product-03.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Only Check Trouser</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$25.50</span>
</div>
</div>
<div class="product_card c">
<div><img src="images/product-11.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$63.16</span>
</div>
</div>
<div class="product_card c">
<div><img src="images/product-12.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Herschel supply</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$63.15</span>
</div>
</div>
<!-- Bag -->
<!-- Shoes -->
<div class="product_card e">
<div><img src="images/product-09.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Converse All Star Hi Plimsolls</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$75.00</span>
</div>
</div>
<!-- Watches -->
<div class="product_card f">
<div><img src="images/product-06.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Vintage Inspired Classic</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$93.20</span>
</div>
</div>
<div class="product_card f">
<div><img src="images/product-15.jpg" alt=""></div>
<div class="product_textbox">
<div class="product_name">
<p>Mini Silver Mesh Watch</p>
<i class="fa-regular fa-heart"></i>
<i class="fa-solid fa-heart heart"></i>
</div>
<span>$86.85</span>
</div>
</div>
</div>
<div class="product_a"><a href="#">Load More</a></div>
</div>
</section>
<footer id="footer">
<div class="footer_top container">
<div class="categories">
<h2>Categories</h2>
<ul>
<li>Women</li>
<li>Men</li>
<li>Shoes</li>
<li>Watches</li>
</ul>
</div>
<div class="help">
<h2>Help</h2>
<ul>
<li>Track Order
</li>
<li>Returns</li>
<li>Shipping</li>
<li>FAQs</li>
</ul>
</div>
<div class="get">
<h2>GET IN TOUCH
</h2>
<p>Any questions? Let us know in store at 8th<br> floor, 379 Hudson St, New York, NY 10018 or<br> call us on
(+1) 96 716 6879</p>
<div>
<i class="fa-brands fa-facebook"></i>
<i class="fa-brands fa-instagram"></i>
<i class="fa-brands fa-pinterest"></i>
</div>
</div>
<div class="news">
<h2>Newsletter</h2>
<input type="email" placeholder="email@example.com">
<a href="#">Subscribe</a>
</div>
</div>
<div class="footer_bottom">
<div class="icons">
<img src="./images/icons/icon-pay-01.png" alt="">
<img src="./images/icons/icon-pay-02.png" alt="">
<img src="./images/icons/icon-pay-03.png" alt="">
<img src="./images/icons/icon-pay-04.png" alt="">
<img src="./images/icons/icon-pay-05.png" alt="">
</div>
<div>
<p>Copyright ©2025 All rights reserved | Made with <i class="fa-regular fa-heart"></i> by <a
href="#">Colorlib</a> & distributed by <a href="#">ThemeWagon</a></p>
</div>
</div>
</footer>
</body>
<css>
*{
margin:0;
padding:0;
text-decoration : none;
list-style:none;
box-sizing:border-box;
color: inherit;
}
.container {
width: 80%;
margin: 0 auto;
}
.header_top{
background-color: black;
font-size: 12px;
}
#header_top{
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
color: aliceblue;
}
#header_top .header_right{
display: flex;
justify-content: space-between;
align-items: center;
}
.header_right a{
border: 1px solid ;
padding: 10px;
}
/* nav start */
.navline{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20px;
margin-bottom: 20px;
}
.nav_left{
display: flex;
justify-content: space-between;
align-items: center;
}
.nav_left img{
margin-right: 50px;
}
.main_menu{
display: flex;
justify-content: space-between;
align-items: center;
}
.main_menu li{
margin-right: 30px;
font-weight: 500;
}
.main_menu>li:first-child{
color: #6c7ae0;
}
.main_menu li a:hover{
color: #6c7ae0;
}
.menuList_Home{
position: relative;
}
.sub_menu{
position: absolute;
top: 40px;
left: 0;
width: 170px;
background-color: white;
border: 1px solid black;
color: gray;
z-index: 10;
}
.sub_menu li{
padding: 10px;
}
.display_none{
display: none;
}
/* nav dropdown end */
.nav_icon{
display: flex;
justify-content: space-between;
align-items: center;
}
.nav_icon div{
margin-right: 30px;
}
/* nav end */
/* slider section start */
.slidebox{
width: 100%;
margin: 0 auto;
white-space: nowrap;
position: relative;
overflow: hidden;
}
.slides{
width: 100%;
font-size: 0;
}
.slide{
width: 100%;
font-size: 15px;
display: inline-block;
position: relative;
transition: all 0.5s;
}
/* textbox */
.slide img{
width: 100%;
}
.textbox{
position: absolute;
display: inline-block;
top: 40%;
left: 10%;
}
.textbox h3{
font-size: 30px;
}
.textbox h2{
font-size: 50px;
margin-bottom: 50px;
}
.textbox a{
display: inline-block;
text-align: center;
width: 150px;
padding: 10px;
border-radius: 30px;
background-color: #717fe0;
color: white;
font-size: 15px;
font-weight: 600;
}
.textbox a:hover{
color: aliceblue;
background-color: black;
}
/* 메인 섹션 기준으로 버튼position */
#slider{
position: relative;
}
.controlbox{
width: 100%;
position: absolute;
top: 50%;
transform: translateY(-50%);
display: flex;
justify-content: space-between;
}
.controlbox div i{
width: 50%;
font-size: 50px;
padding: 30px;
}
.controlbox i:hover{
color: #717fe0;
}
/* banner start */
#banner{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 50px;
margin-bottom: 100px;
/* background-color: purple; */
}
.bb1, .bb2, .bb3{
position: relative;
width: 32%;
}
.b1, .b2, .b3{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
padding: 30px;
}
.banner_textbox:hover{
background-color: #717fe0;
color: white;
opacity: 0.7;
transition: all 0.5s;
}
.banner_textbox a{
display: inline-block;
margin-top: 120px;
font-weight: 600;
color: white;
}
.banner_imgbox{
width: 100%;
border: 1px solid black;
}
.banner img{
width: 100%;
}
/* product start */
#product h2{
font-size: 40px;
text-align: left;
}
.product_list{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 50px;
}
.product_list ul{
display: flex;
justify-content: space-between;
}
.product_list ul li{
margin-right: 30px;
}
.product_icon{
display: flex;
justify-content: space-between;
align-items: center;
color: gray;
}
.product_icon i{
font-size: 12px;
margin-right: 5px;
}
.product_icon div:hover{
background-color: #717fe0;
color: white;
transition: all 0.5s;
}
.product_icon div{
width: 100px;
text-align: center;
border: 1px solid #b2b2b2;
padding: 8px;
}
.product_icon div:first-child{
margin-right: 8px;
}
/* card start */
.cardbox{
display: flex;
align-items: center;
/* justify-content: space-between; */
margin: 0 auto;
flex-wrap: wrap;
margin-bottom: 50px;
}
.product_card{
width: 22%;
/* flex: 0 1 calc(25% - 20px); */
margin-right: 30px;
}
.product_card img{
width: 100%;
}
.product_name{
display: flex;
justify-content: space-between;
padding: 10px 0;
position: relative;
}
.heart{
position: absolute;
right: 0;
color: transparent;
}
.heart:hover{
color: #717fe0
}
.product_textbox{
margin-bottom: 30px;
}
/* tab start */
.tab:hover{
color: #ccc;
text-decoration: underline;
}
.tab-content{
/* display: none; */
padding: 20px;
border: 1px solid #ccc;
}
.tab.active {
text-decoration: underline;
}
.all.active{
display: block;
}
/* Load More 버튼 */
.product_a{
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 150px;
}
.product_a a{
text-align: center;
width: 12%;
padding: 13px;
border-radius: 30px;
background-color: #e6e6e6;;
font-weight: 600;
}
.product_a a:hover{
color: white;
background-color: black;
}
/* footer top start*/
#footer{
background-color: black;
padding: 70px 0;
}
.footer_top{
display: flex;
justify-content: space-between;
align-items: center;
color: white;
margin-bottom: 100px;
}
.categories h2{
font-size: 17px;
margin-bottom: 20px;
}
.categories li{
padding: 8px 0;
color: #b2b2b2;
font-size: 15px;
}
.help h2{
margin-bottom: 20px;
font-size: 17px;
}
.help li{
padding: 8px 0;
color: #b2b2b2;
font-size: 15px;
}
.get h2{
margin-bottom: 40px;
font-size: 17px;
}
.get p{
font-size: 15px;
color: #b2b2b2;
margin-bottom: 35px;
}
.get i{
margin-right: 15px;
color: #b2b2b2;
}
.get i:hover{
color: #717fe0;
cursor: pointer;
}
.news{
display: flex;
flex-direction: column;
}
.news h2{
margin-bottom: 30px;
font-size: 17px;
}
.news input{
width: 300px;
padding: 8px;
background-color: transparent;
margin-bottom: 15px;
}
.news input::placeholder {
font-size: 15px;
color: #b2b2b2;
}
.news a{
width: 45%;
padding: 15px;
text-align: center;
border-radius: 30px;
background-color: #717fe0;
font-weight: 600;
}
.news a:hover{
color: #717fe0;
background-color: white;
}
/* .categories, .help, .get, .news{
width: 25%;
} */
/* footer bottom start */
.footer_bottom{
text-align: center;
color:#b2b2b2;
}
.icons{
margin-bottom: 20px;
}
.footer_bottom p{
font-size: 13px;
}
.footer_bottom a{
color: #007bff;
}
.footer_bottom a:hover{
opacity: 0.5;
}
<js>
1)dropdown
//dropbox.js 코드
// 1. 셀렉트하기
let home = document.querySelector(".menuList_Home");
let submenu = document.querySelector(".sub_menu");
//2.이벤트 할당하기
home.addEventListener("click", showSubList);
// //3. 함수 선언하기
function showSubList(){
console.log(submenu);
submenu.classList.toggle('display_none');
}
//요소 자동으로 아이디가 선택?
//id 는 전역변수처럼 사용가능(주의 할 것!) ->변수 따로 주는 게 좋음
// function showSubList(){
// if(cnt%2 == 0){ //클릭횟수가 짝수
// submenu.style.display = "block";
// }else{ //클릭횟수가 홀수
// submenu.style.display = "none";
// }
// cnt++;
// }
2)slider
//1.selector
//처음만 선택됨
let left = document.querySelector(".left");
let right = document.querySelector(".right");
let slides = document.querySelectorAll(".slide"); //All
//2. 이벤트 할당
left.addEventListener("click", leftsliding);
right.addEventListener("click", rightsliding);
let index = 0; //클릭할 때마다 실행
//3.함수 선언
function leftsliding() {
//4.함수 기능 정의
index--; //1씩 줄어짐
if(index < 0) {
index = (slides.length -1);
}
//콘텐츠 묶음 > 요소 3개 : NodeList객체->forEach메서드
slides.forEach(function(slide){ //value, index, array
//div.slide(div인데 class가 slide인 요소) 반복문
//slide = <div class = "slide"></div>
console.log(slide);
slide.style.transform = `translateX(${index*(-100)}%)`;
});
}
function rightsliding() {
index ++; //1씩 증가
if(index >= (slides.length)) {
index = 0;
}
slides.forEach(function(slide){
slide.style.transform = `translateX(${index*(-100)}%)`;
});
}
3)tab
//1.셀렉트 하기
let tabs = document.querySelectorAll('.tab');
//2.이벤트 할당하기
for(let i = 0; i < tabs.length; i++) {
tabs[i].addEventListener('click', tabIdCalculator);
} //텝메뉴
//텝메뉴-텝컨텐츠 연결: id 속성
function tabIdCalculator() {
let tabId = this.id;
activateTab(this);
showTabContent(tabId);
}
activateTab(tabs[0]); // 탭 메뉴
showTabContent('a'); //탭 컨텐츠
function activateTab(tab) {
// 모든 탭 비활성화
let tabs = document.querySelectorAll('.tab');
for (let i = 0; i < tabs.length; i++) {
tabs[i].className = 'tab'; // 클래스 이름을 초기화
}
// 선택한 탭 활성화
tab.className = 'tab active'; // active 클래스 추가
console.log(tab.className);
}
function showTabContent(tabId) {
let contents = document.querySelectorAll('.product_card');
for(let i = 0; i<contents.length; i++) {
contents[i].style.display = 'none';
}
console.log(tabId);
let activeContents = document.querySelectorAll("." + tabId);
console.log("length : "+activeContents.length);
if(activeContents.length != 0) {
activeContents.forEach(function(activeContent){
activeContent.style.display = 'block';
});
}
}
참고사이트)
https://themewagon.github.io/cozastore/
'웹프로그래밍 > JavaScript' 카테고리의 다른 글
프로그래밍 언어 응용 39일차 (25/1/6) (0) | 2025.01.06 |
---|---|
프로그래밍 언어 응용 38일차 (25/1/3) (0) | 2025.01.03 |
프로그래밍 언어 응용 36일차 (24/12/31) (0) | 2024.12.31 |
프로그래밍 언어 응용 35일차 (24/12/30) (2) | 2024.12.30 |
프로그래밍 언어 응용 34일차 (24/12/27) (1) | 2024.12.27 |