Mini Projects

Knowledge Timeline (3) Boxes & Arrows

윰윰로그 2020. 7. 8. 19:18
#timeline ul {
  background: var(--primary-color);
  padding: 50px 0;
}

/* Create Line */
#timeline ul li {
  list-style: none;
  position: relative;
  width: 6px;
  margin: 0 auto;
  padding-top: 50px;
  background: #fff;
}

ul에 한번 더 배경색

위아래 padding

 

li 

list-style: none; -> 점 없애기

나중에 position:absolute; element 나올 것

width: 6px;

margin: 0 auto; -> 중앙 배치

padding-top: 위 공간

background:#fff; -> 흰색 => 중앙 흰 라인

 

 

/* Boxes */
#timeline ul li div {
  position: relative;
  bottom: 0;
  width: 400px;
  padding: 1rem;
  background: var(--secondary-color);
  transition: all 0.5s ease-in-out;
}

li 속 div 스타일

 

 

/* Right Side */
#timeline ul li:nth-child(odd) div {
  left: 40px;
}

/* Left Side */
#timeline ul li:nth-child(even) div {
  left: -434px;
}

li가 아니라 li 속 div들 위치 바꾸기

홀수번째 li 속 div들은 오른쪽으로 더 이동했고

짝수번째 li 속 div들은 왼쪽으로 더 이동했다.

 

 

/* Dots */
#timeline ul li:after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 25px;
  height: 25px;
  background: var(--secondary-color);
}

li 뒤에 dot을 만들었다!

 

 

 

/* Dots */
#timeline ul li:after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 25px;
  height: 25px;
  background: inherit;
  transform: translateX(-50%);
  border-radius: 50%;
}

transform:translateX()를 쓰면 위치를 이동시켜 준다.

처음 left:50%;를 했었다. 다시 왼쪽으로 50% 이동 시키고 싶어서

transform: translateX(-50%);

 

border-radius를 이용해서 동그란 점으로

 

 

 

/* Dots */
#timeline ul li:after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 25px;
  height: 25px;
  background: inherit;
  transform: translateX(-50%);
  border-radius: 50%;
  transition: background 0.5s ease-in-out;
}

transition까지

 

 

 

 

 

Arrow 만들 때 border을 이용할 것이기 떄문에

width, height은 없다.

하얀 점이 생겼다