18. Cafe25 HTML에 CSS 적용

서현우·2022년 3월 16일
0

HTML

목록 보기
11/20

style.css

@import url('https://fonts.googleapis.com/css2?family=Nanum+Gothic+Coding&display=swap');

/* 자주쓰는 색을 변수로 --변수명 */
:root {
  --primary-color: #047aed;
  --secondary-color: #1c3fa8;
  --dark-color: #002240;
  --light-color: #f4f4f4;
  --success-color: #5cb85c;
  --error-color: #d9534f;
}

/* 각 태그들의 기본 마진/패딩을 초기값 0으로 하고 박스모델 기준을 보더-박스로 한다. */
* {
  /* *은 모든 태그들을 선택 */
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

body {
  font-family: 'Nanum Gothic Coding', monospace;
  color: #333;
  line-height: 1.6; /* 세로 줄 간격 1.6배 160% */
}

ul{
  list-style-type: none; /* 리스트 앞의 • 없애기 */
}
a {
  text-decoration: none; /* a태그 링크 없애기 */
  color: #333;
}

h1,
h2 {
  font-weight: 300;
  line-height: 1.2;
  margin: 10px 0;
}

p {
  margin: 10px 0;
}

img {
  /* 화면에 100%로 맞춤 */
  width: 100%;
}

code,
pre {
  background: #333;
  color: #fff;
  padding: 10px;
}

.hidden {
  /* 화면에 표시 안함 display:none과 같음 */
  visibility: hidden; 
  height: 0;
}

/* 네브바 메뉴 */
.navbar {
  background-color: var(--primary-color);
  color: #fff;
  height: 70px;
}
.navbar ul {
  display: flex;
}
.navbar a{
  color: #fff;
  padding: 10px;
  margin: 0 5px;
}
.navbar .flex {
  justify-content: space-between;
}
.navbar a:hover{
  border-bottom: 2px solid #fff;
}

/* 섹션 쇼케이스  */
.showcase {
  height: 400px;
  background-color: var(--primary-color);
  color: #fff;
  position: relative;
}
.showcase h1 {
  font-size: 40px;
}
.showcase p {
  margin: 20px 0;
}
.showcase .grid {
  overflow: visible; /* 지정된 구역을 넘어갔을경우도 보이게 */
  grid-template-columns: 55% auto;
  gap: 30px;
}
.showcase-text {
  /* 애니메이션 왼쪽에서 */
  animation: slideInFromLeft 1s ease-in;
}
.showcase-form {
  /* 상대좌표 원래위치 기준으로 top,left,bottom,right */
  position: relative;
  top: 60px;
  height: 350px;
  width: 400px;
  z-index: 100;
  justify-self: flex-end;
  animation: slideInFromRight 1s ease-in;
}

.showcase-form .form-control {
  margin: 30px 0;
}

.showcase-form input[type="text"],
.showcase-form input[type="email"] {
  border: 0;
  border-bottom: 1px solid #b4becb;
  width: 100%;
  padding: 3px;
  font-size: 16px;
}

.showcase-form input:focus {
  outline: none;
}

.showcase::before,
.showcase::after {
  content: '';
  position: absolute;
  height: 100px;
  bottom: -70px;
  right: 0;
  left: 0;
  background-color: #fff;
  transform: skewY(-3deg);
}

/* 섹션 stats */
.stats {
  padding-top: 100px;
  animation: slideInFromBottom 1s ease-in;
}

.stats-heading {
  max-width: 500px;
  margin: auto;
}

.stats .grid h3 {
  font-size: 35px;
}

.stats .grid p {
  font-size: 20px;
  font-weight: bold;
}

/* 섹션 cli */
.cli .grid {
  grid-template-columns: repeat(3,1fr);
  grid-template-rows: repeat(2,1fr);
}
/* >자식태그 */
.cli .grid > *:nth-child(1){
  grid-column: 1 /span 2;
  grid-row: 1 /span 2;
}

/* 섹션 클라우드 */
.cloud .grid{
  grid-template-columns: 4fr 3fr;
}

/* 섹션 랭귀지 */
.languages .flex {
  flex-wrap: wrap;
}

.languages .card {
  text-align: center;
  margin: 18px 10px 40px;
  /* transform 을 쓸때 0.2초 천천히 시작 */
  transition: transform 0.2s ease-in;
}

.languages .card:hover {
  transform: translateY(-15px);
}

.languages .card h4 {
  font-size: 20px;
  margin-bottom: 10px;
}

/* 특징 페이지 */
.features-head img,
.docs-head img {
  width: 200px;
  justify-self: flex-end;
}

.features-sub-head img {
  width: 300px;
  justify-self: flex-end;
}

.features-main .card > i {
  /* 카드 안의 아이콘과 글자사이 거리 */
  margin-right: 20px;
}

.features-main .grid {
  padding: 30px;
}

.features-main .grid > *:nth-child(1){
  grid-column: 1 /span 3;
}

.features-main .grid > *:nth-child(2){
  grid-column: 1 /span 2;
}

/* 문서 페이지 */
.docs-main h3{
  margin: 20px 0;
}

.docs-main .grid {
  grid-template-columns: 1fr 2fr;
  align-items: flex-start;
}

.docs-main nav li {
  font-size: 17px;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #ccc;
}

.docs-main a:hover {
  font-weight: bold;
}

/* footer 섹션 */
.footer .social a {
  margin: 0 10px;
}

.fa-github:hover {
  color: #000000;
}

.fa-facebook:hover {
  color: #1773ea;
}

.fa-instagram:hover {
  color: #b32e87;
}

.fa-twitter:hover {
  color: #1c9cea;
}

/* 애니메이션 */
/* 왼쪽에서 오른쪽으로 */
@keyframes slideInFromLeft {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(0);
  }
}
/* 오른쪽에서 왼쪽으로 */
@keyframes slideInFromRight {
  0% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(0);
  }
}
/* 위에서 아래로 */
@keyframes slideInFromTop {
  0% {
    transform: translateY(-100%);
  }

  100% {
    transform: translateX(0);
  }
}
/* 아래에서 위로 */
@keyframes slideInFromBottom {
  0% {
    transform: translateY(100%);
  }

  100% {
    transform: translateX(0);
  }
}


/* 반응형 페이지 */
/* 태블릿 가로 사이즈 850 이하  */
@media (max-width: 850px) {
  .grid,
  .showcase .grid,
  .stats .grid,
  .cli .grid,
  .cloud .grid,
  .features-main .grid,
  .docs-main .grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .showcase {
    height: auto;
  }

  .showcase-text {
    text-align: center;
    margin-top: 40px;
    animation: slideInFromTop 1s ease-in;
  }

  .showcase-form {
    justify-self: center;
    margin: auto;
    animation: slideInFromBottom 1s ease-in;
  }

  .cli .grid > *:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  .features-head,
  .features-sub-head,
  .docs-head {
    text-align: center;
  }

  .features-head img,
  .features-sub-head img,
  .docs-head img {
    justify-self: center;
  }

  .features-main .grid > *:first-child,
  .features-main .grid > *:nth-child(2) {
    grid-column: 1;
  }
}

/* Mobile  가로 사이즈 500px 이하*/
@media (max-width: 500px) {
  .navbar {
    height: 110px;
  }

  .navbar .flex {
    flex-direction: column;
  }

  .navbar ul {
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
  }

  .showcase-form {
    width: 300px;
  }
  
  .languages .container {
    margin: 0;
    padding: 0 5px;
  }

  .languages .flex{
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4,1fr);
  }
}

utilities.css

/* 자주 사용하는 형태의 CSS 들을 묶어서 클래스로 사용*/
/* 여기에 사용한 CSS는 index, docs, features 공통사용 */
.container {
  max-width: 1100px;
  margin: 0 auto; 
  overflow: auto;
  padding: 0 40px;
}

.card {
  background-color: white;
  color: #333;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  padding: 20px;
  margin: 10px;
}

/* 버튼관련 CSS */
.btn {
  display: inline-block;
  padding: 10px 30px;
  cursor: pointer;
  /* 변수사용시 var(변수이름) */
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 5px;
}
/* btn-outline 버튼일때 */
.btn-outline {
  background-color: transparent;
  border: 1px solid #fff;
}
.btn:hover{
  transform: scale(0.98);
}
/* 벡그라운드 색과 글자색 & 버튼색과 글자색 */
/* 바탕색이 어두우면 글자는 밝은색, 바탕이 밝으면 글자는 어두운 */
.bg-primary,
.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.bg-secondary,
.btn-secondary {
  background-color: var(--secondary-color);
  color: #fff;
}

.bg-dark,
.btn-dark {
  background-color: var(--dark-color);
  color: #fff;
}

.bg-light,
.btn-light {
  background-color: var(--light-color);
  color: #333;
}

/* 예) Footer */
.bg-primary a,
.btn-primary a,
.bg-secondary a,
.btn-secondary a,
.bg-dark a,
.btn-dark a {
  color: #fff;
}

/* 글자 색 */
.text-primary {
  color: var(--primary-color);
}

.text-secondary {
  color: var(--secondary-color);
}

.text-dark {
  color: var(--dark-color);
}

.text-light {
  color: var(--light-color);
}

/* 글자 크기 */
.lead {
  font-size: 20px;
}

.sm {
  font-size: 1rem;
}

.md {
  font-size: 2rem;
}

.lg {
  font-size: 3rem;
}

.xl {
  font-size: 4rem;
}

/* 좌우 정렬 */
.text-center {
  text-align: center;
}

/* 경고창 */
.alert {
  background-color: var(--light-color);
  padding: 10px 20px;
  font-weight: bold;
  margin: 15px 0;
}

.alert i {
  margin-right: 10px;
}

.alert-success {
  background-color: var(--success-color);
  color: #fff;
}

.alert-error {
  background-color: var(--error-color);
  color: #fff;
}

/* 그리드 정렬 (절반:절반) */
.grid {
  display: grid;
  /* grid-template-columns: 1fr 1fr; */
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  justify-content: center;
  align-items: center;
  height: 100%;
}
/* 3등분하는 grid */
.grid-3 {
  /* 가로 3등분을 덮어씀 */
  grid-template-columns: repeat(3, 1fr);
}
/* 플렉스 */
.flex {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

/* 마진 */
.my-1 {
  margin: 1rem 0;
}

.my-2 {
  margin: 1.5rem 0;
}

.my-3 {
  margin: 2rem 0;
}

.my-4 {
  margin: 3rem 0;
}

.my-5 {
  margin: 4rem 0;
}

.m-1 {
  margin: 1rem;
}

.m-2 {
  margin: 1.5rem;
}

.m-3 {
  margin: 2rem;
}

.m-4 {
  margin: 3rem;
}

.m-5 {
  margin: 4rem;
}

/* 패딩 */
.py-1 {
  padding: 1rem 0;
}

.py-2 {
  padding: 1.5rem 0;
}

.py-3 {
  padding: 2rem 0;
}

.py-4 {
  padding: 3rem 0;
}

.py-5 {
  padding: 4rem 0;
}

.p-1 {
  padding: 1rem;
}

.p-2 {
  padding: 1.5rem;
}

.p-3 {
  padding: 2rem;
}

.p-4 {
  padding: 3rem;
}

.p-5 {
  padding: 4rem;
}
profile
안녕하세요!!

0개의 댓글