네이버 리빙 메뉴 만들기, 카카오톡 친구목록 페이지 만들기, tripadvisor홈페이지 만들기(+animation), 텐바이텐 홈페이지 일부 만들기
리스트 메뉴에 마우스 커서를 올리면 제목에 밑줄 + 사진이 부드럽게 확대되는 transform:scale()
, transition
을 사용하였다.
<hr>
태그 사용<hr class="border-line" noshade>
.border-line {
border: dashed 1px #ededed;
width: 95%;
opacity: 0.5;
}
github소스코드-tripadvisor+animation
<header>
버튼 리스트 구현rgba()
로 설정해주었다. 또 버튼 요소는 마우스 올렸을 때 커서 모양이 바뀌지 않아서 cursor:pointer
로 직접 추가해주었다.header .header-nav ul li {
display: inline-block;
vertical-align: middle;
}
header .header-nav ul li button {
border: none;
background-color: rgba(1,1,1,0);
font-size: 15px;
padding: 10px;
border-radius: 20px;
}
header .header-nav ul li button:hover {
background-color: rgba(237, 237, 237, 1);
}
header .header-nav ul li .btn-signin {
background-color: rgba(0,0,0,1);
color: white;
}
header .header-nav ul li .btn-signin:hover {
background-color: rgba(0,0,0,0.5);
}
<main>
의 nav 메뉴 구현<header>
의 버튼 리스트와 유사하지만 flex
와justify-content:space-around
속성을 이용해 양쪽 내부 공백 포함해서 x축 정렬하였다.또한 마우스을 올렸을 때 효과로 글자색과 배경색을 부드럽게 변화시키기 위해 transition
을 사용하였다. 공백도 고려하며 메뉴 요소의 크기를 동일하게 맞추기 위해 넓이를 width:23%
으로 주었다.main .nav-menu ul {
display: flex;
justify-content: space-around;
align-items: center;
height: 100px;
}
main .nav-menu ul li a {
padding: 20px;
display: block;
text-align: left;
border: solid 1px #000000;
border-radius: 15px;
transition: background-color 0.1s, color 0.1s;
}
main .nav-menu ul li a:hover {
background-color: #000000;
color: white;
}
<main>
의 숙소 리스트 구현width:100%
로 설정했다..stay-lists div ul li {
box-sizing: border-box;
display: inline-block;
vertical-align: middle;
width: 250px;
overflow: hidden;
}
.stay-lists div ul li a .stay-img {
width: 100%;
transition: opacity 0.1s;
}
.stay-lists div ul li a:hover .stay-img {
opacity: 0.7;
}
.stay-lists div ul li a:hover .stay-info h3 {
transition: opacity 0.1s, text-decoration 0.1s;
}
.stay-lists div ul li a:hover .stay-info h3 {
text-decoration: underline;
opacity: 0.7;
}
animation 실습을 못 해봐서 그냥 임의로 비행기가 날아가는 모습을 만들어보기로 했다. 위 비행기는 직접 제작했고 아래는 Stylie를 사용해 만들었다.
left
, top
등을 사용하기 위해 position:relative
적용transform: rotate()
left
, top
keyframe
을 늘렸는데 어차피 경로 상의 frame 값을 그대로 쓴거라 효과가 없었던 것 같다. 완만하게 하려면 위치 값을 경로 직선 상의 점 말고 다른 걸로 바꿔야 할 듯. 확인 차 25%지점과 75%지점의 코드를 주석처리해보니 결과가 똑같음..ㅠ.sky .airplane-img {
position: relative;
width:150px;
height: 150px;
left: 0;
top: 100px;
animation: airplaneFly 2s linear 0.5s 5 normal backwards;
}
@keyframes airplaneFly {
0% {
transform: rotate(-20deg);
left: 0;
top: 100px;
}
25% {
transform: rotate(-10deg);
left: 100;
top: 50px;
}
50% {
transform: rotate(0deg);
left: 200px;
top: 0px;
}
75% {
transform: rotate(10deg);
left: 100;
top: 50px;
}
100% {
transform: rotate(20deg);
left: 400px;
top: 100px;
}
}
완만한 포물선을 만들고 싶어서 Stylie를 한번 사용해보았다. 근데 포물선 도대체 어떻게 만드는지 감이 잘 안 온다. 거기다 keyframe size를 낮췄더니 비행기가 미묘하게 움찔대면서 움직이는게 보인다. 여기다가 rotate()
를 추가해주면 좀 더 나을 것 같긴 하다.
.sky2 .airplane-path {
animation-name: airplane-path-keyframes;
animation-duration: 2000ms;
animation-delay: 0ms;
animation-fill-mode: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
transform-origin: 0 0;
}
@keyframes airplane-path-keyframes {
0% {transform:translate(0px, 0px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
16.67% {transform:translate(88.4291px, -36.6667px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
33.33% {transform:translate(141.5709px, -73.3333px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
50% {transform:translate(230px, -110px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
66.67% {transform:translate(332.2702px, -71.3333px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
83.33% {transform:translate(393.7298px, -32.6667px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
100% {transform:translate(496px, 6px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate(-50%, -50%);}
}html::after { content: url(https://ga-beacon.appspot.com/UA-42910121-1/stylie?pixel); position: absolute; left: -999em; }
github소스코드-텐바이텐
일지를 다 쓰고 다른 분 블로그를 보다가 텐바이텐 메뉴를 만드신 걸 봤다. 마침 안보이다가 나타나는 메뉴 실습을 하기 적절한 예시를 못 찾고 있기도 했고 자극도 되서 나도 만들어보기로 했다.
flex
, justify-content:space-between
, 비율 width
같이 활용.left .img-lists {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
}
.left .img-lists li {
width: 30%;
}
display:inline-block
속성을 줘서 크기 및 색상을 지정하고 text-align:center
, padding-top
로 글자를 중간 아래로 움직였다. transform:rotate(45deg)
로 회전시킨 후 right
, top
속성을 이용해 위치를 움직여줬다. 이때 부모 태그에 overflow:hidden
을 적용해 부모 태그 밖으로 나가면 보이지 않도록 했다. 마지막으로 transition
을 적용할 때 all
이라는 속성값을 주면 모든 transition-property
를 선택할 수 있다는 걸 알게 되었다..left .img-lists li .discount {
display: inline-block;
width: 50px;
height: 50px;
padding-top: 35px;
box-sizing: border-box;
transform: rotate(45deg);
position: absolute;
background-color: red;
color: white;
right:-25px;
top: -25px;
text-align: center;
transition: all 0.2s;
}
.left .img-lists li:hover .discount {
right:-100px;
top: -100px;
}
top
값만 조절했다.flex
와 justify-content:space-around
를 사용했더니 분산은 잘 되었지만 리스트 요소 사이 남는 공간이 많았다.vertical-align
, float
, flex
다 해봐도 옆으로 안 감.<span>
에 inline-block
속성을 부여해서 높이, 길이 주고 text-align:center
준건 좋았는데 내부 텍스트를 바닥으로 내릴 수가 없었다.<hr>
이라는 태그가 있었다.강의 분량을 어제 듣기도 했고 또 강의 길이도 짧았기 때문에 오늘은 혼자 만들어보는 활동을 주로 했다. 처음엔 이전 강의에서 다루었던 네이버 리빙 메뉴, 카카오톡 친구 목록 등을 보완하기도 하고 새로운 웹사이트(tripadvisor)도 한번 따라해보았다.
여러 웹사이트를 따라하면서 느낀 건데, 마우스를 올렸을 때의 움직임은 꽤 정형화되어있는 것 같았다. (예를 들어 이미지는 살짝 커짐. 문자열은 밑줄. 공통적으론 약간 투명해짐)
transform
과 transition
을 이용해 약간의 효과만 추가해줘도 훨씬 더 고급스러운 디자인이 되는 것 같아서 만족스러웠다.
다른 분이 텐바이텐 사이트를 만든 것 보고 어제 배운 거 연습용 예시로 적절한 것 같아서 나도 따라 만들어봤다.