티스토리 뷰
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="sh.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="container">
<div><h2>NEW ARRIVALS</h2></div>
<div id="A">
<div class="text_img">
<img id="sale" src="image/sale.png" alt="">
<div class="img">
<img class="model" src="image/model1.jpg" alt="">
<div class="hover_text">
<p class="zoom">ZOOM</p>
<p class="see">VIEW</p>
</div>
</div>
<div class="text">
<p>BERRY LACE DRESSE</p>
<div class="push">
<p id="cash">$29.00</p>
<button>ADD TO CART</button>
</div>
</div>
</div>
<div class="text_img">
<div class="img">
<img class="model" src="image/model2.jpg" alt="">
<div class="hover_text">
<p class="zoom">ZOOM</p>
<p class="see">VIEW</p>
</div>
</div>
<div class="text">
<p>BERRY LACE DRESSE</p>
<div class="push">
<p id="cash">$29.00</p>
<button>ADD TO CART</button>
</div>
</div>
</div>
<div class="text_img">
<div class="img">
<img class="model" src="image/model6.jpg" alt="">
<div class="hover_text">
<p class="zoom">ZOOM</p>
<p class="see">VIEW</p>
</div>
</div>
<div class="text">
<p>BERRY LACE DRESSE</p>
<div class="push">
<p id="cash">$29.00</p>
<button>ADD TO CART</button>
</div>
</div>
</div>
<div class="text_img">
<img id="new" src="image/new.png" alt="">
<div class="img">
<img class="model" src="image/model4.jpg" alt="">
<div class="hover_text">
<p class="zoom">ZOOM</p>
<p class="see">VIEW</p>
</div>
</div>
<div class="text">
<p>BERRY LACE DRESSE</p>
<div class="push">
<p id="cash">$29.00</p>
<button>ADD TO CART</button>
</div>
</div>
</div>
<div class="text_img">
<div class="img">
<img class="model" src="image/model5.jpg" alt="">
<div class="hover_text">
<p class="zoom">ZOOM</p>
<p class="see">VIEW</p>
</div>
</div>
<div class="text">
<p>BERRY LACE DRESSE</p>
<div class="push">
<p id="cash">$29.00</p>
<button>ADD TO CART</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
*{
padding: 0;
margin: 0;
text-decoration: none;
list-style: none;
box-sizing: border-box;
background-color: rgb(231, 228, 228);
}
.container{
width: 60%;
margin: 0 auto;
padding: 20px;
}
h2{
text-align: left;
padding: 20px;
}
#A{
padding: 0 10px;
display: flex;
width: 100%;
/* border: 1px solid blue; */
/* padding: 10px; */
}
div.text_img{
position: relative;
width: 20%;
/* border: 1px solid purple; */
padding: 10px;
margin: 0 5px;
background-color: white;
}
#new{
position: absolute;
top: 0;
left: 100%;
transform: translate(-100%, 0);
z-index: 8;
background-color: transparent;
/* border: 5px solid red; */
}
#sale{
position: absolute;
top: 0%;
left: 17%;
transform: translate(-100%, 0);
z-index: 8;
background-color: transparent;
}
.img{
/* position: relative; */
background-color: white;
}
img.model{
position: relative;
width: 100%;
height: auto;
}
div.text{
padding: 10px 0;
background-color: white;
/* border: 1px solid orange; */
}
p{
background-color: transparent;
}
div.push{
padding: 10px 0;
background-color: white;
display: flex;
justify-content: space-around;
}
#cash{
font-size: 23px;
color: orangered;
background-color: white;
}
button{
background-color: white;
color: lightgray;
border: 1px solid lightgray;
width: 50%;
}
div.img{
position: relative;
}
div.img:hover .model{
opacity: 0.5;
/* background-color: black; */
}
div.hover_text{
display: flex;
justify-content: space-between;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
opacity: 0;
transition: opacity 0.3s;
background-color: transparent;
}
.img:hover .hover_text{
opacity: 1;
}
.zoom:hover {
background-color: orangered;
}
.see:hover{
background-color: orangered;
}
p.see{
border: 1px solid white;
color: white;
margin: 0 10px;
width: 60px;
padding-bottom: 5px;
}
p.zoom{
border: 1px solid white;
color: white;
margin: 0 10px;
width: 60px;
padding-bottom: 5px;
}
button:hover{
background-color: orangered;
}
1일차에 발생했던 relative 위치를 다시 선정했다.
text_img에 relative를 위치했더니 문제가 해결되었다.
relative는 위치하고자하는 곳의 부모에 위치해야한다.
div.text_img{
position: relative;
width: 20%;
/* border: 1px solid purple; */
padding: 10px;
margin: 0 5px;
background-color: white;
}
'코딩 > 오류 노트' 카테고리의 다른 글
javascript 코드 위치에 따른 오류 (2) | 2023.11.23 |
---|---|
[7주 2일차] border사용 (1) | 2023.11.21 |
[7주 1일차] HTML CSS 코드 수정 (0) | 2023.11.21 |
[7주 1일차] HTML CSS 코드 수정 (0) | 2023.11.20 |
public (0) | 2023.11.03 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday