시작 실패
Your requested instance type (t2.micro) is not supported in your requested Availability Zone (ap-northeast-2b). Please retry your request by not specifying an Availability Zone or choosing ap-northeast-2a, ap-northeast-2c.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
It is required that your private key files are NOT accessible by others. This private key will be ignored.
---
const Job = () => {
const [pos, setPos] = useState(0);
const slideLeft = () => {
setPos(prev => {
if (prev === 0) {
return imgArr.length - 1;
} else {
return prev - 1;
}
});
};
const slideRight = () => {
setPos(prev => {
if (prev === imgArr.length - 1) {
return 0;
} else {
return prev + 1;
}
});
};
const imgArr = [
'/images/cake.jpeg',
'/images/cake2.jpeg',
'/images/cake.jpeg',
];
return (
<div className="slider">
<ul
style={{
width: `${imgArr.length * 100}%`,
marginLeft: `${-pos * 100}%`,
}}
>
{imgArr.map((url, index) => (
<li
key={index}
style={{ width: `calc(100% / ${imgArr.length})` }}
>
<div
className="articleThumbnail"
style={{ backgroundImage: `url(${url})` }}
/>
</li>
))}
</ul>
<i
className="fa fa-angle-left slideLeft"
aria-hidden="true"
onClick={slideLeft}
/>
<i
className="fa fa-angle-right slideRight"
aria-hidden="true"
onClick={slideRight}
/>
</div>
);
.slider {
position: relative;
height: calc((80vw - 365px) * 0.75);
overflow: hidden;
border: 1px solid #e0e2e3;
border-radius: 3px;
ul {
display: flex;
height: 100%;
transition: 0.6s ease-in-out;
.articleThumbnail {
width: 100%;
height: 100%;
background-size: cover;
background-position: 50%;
}
}
.slideLeft,
.slideRight {
position: absolute;
bottom: calc(50% - 25px);
display: flex;
align-items: center;
padding: 0 25px;
height: 50px;
color: #9299a1;
font-size: 26px;
cursor: pointer;
}
.slideLeft {
left: 10px;
}
.slideRight {
right: 10px;
justify-content: flex-end;
}
}
HTML
<ul>, <li>
CSS
overflow: hidden; width: 100% * num; margin-left: pos * 100%;
JavaScript & React
const [pos, setPos] = useState(0);
참고
'TIL' 카테고리의 다른 글
[TIL-149] 위코드 59일차: (0) | 2022.03.23 |
---|---|
[TIL-148] 위코드 57일차: formData (0) | 2022.03.21 |
[TIL-146] 위코드 53일차: React에서 파일 다운로드하기 (0) | 2022.03.17 |
[TIL-145] 위코드 52일차: (0) | 2022.03.16 |
[TIL-144] 위코드 51일차: (0) | 2022.03.15 |