list-style: none;
사용하기<section class="section-how grid grid--2-cols">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</section>
<section class="section-how grid grid--3-cols">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</section>
.grid{
display: grid;
gap: 9.6rem;
}
.grid--2-cols{
grid-template-columns: repeat(2,1fr);
}
.grid--3-cols{
grid-template-columns: repeat(3,1fr);
}
.grid 클래스 외에 변형을 주어 원하는 column 개수 별로 그리드를 재사용할 수 있다.
.container{
max-width: 120rem;
margin: 0 auto;
}
<section class="section-how container grid grid--2-cols">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</section>
<div>
를 만들어 준다.<section class="section-how">
<div class="container grid grid--2-cols">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</div>
</section>
<div class="step-img-box">
<img
src="img/app/app-screen-3.png"
class="step-img"
alt="iPohone
app delivery screen"
/>
</div>
step-img-box
안에 ::before
를 사용해 자식 요소를 만든다.width: 60%;
는 적용되지만 height: 60%;
는 적용되지 않는다.padding-bottom:60%;
를 사용하면 된다.width: 60%;
와 같은 길이를 가진다..step-img-box::before{
content: "";
display: block;
width: 60%;
/* flexible하기 위해 %를 사용하는 것 */
/* height: 60% 부모 요소의 높이는 설정되어 있지 않아, 60%가 적용되지 않는다. */
padding-bottom: 60%;
/* 원을 만들기 위해, 정사각형을 만들어야 하므로, 높이가 너비와 같은 60%를 만들기 위한 트릭 */
/* 부모 요소의 너비에 의해 정의됨. */
background-color: #fdf2e9;
position: absolute;
/* 주의: 부모 요소 step-img-box에 realtive 설정해주기! */
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border-radius: 50%;
z-index: -1;
}
<div class="container">
<h2 class="heading-featured-in">As featured in</h2>
<div class="logos">
<img src="img/logos/techcrunch.png" alt="Techcrunch logo" />
<img
src="img/logos/business-insider.png"
alt="Business Insider logo"
/>
<img
src="img/logos/the-new-york-times.png"
alt="The New York Times logo"
/>
<img src="img/logos/forbes.png" alt="Forbes logo" />
<img src="img/logos/usa-today.png" alt="USA Today logo" />
</div>
</div>
흑백으로 변경해준다. 우리가 원하는 것은 전부 회색빛을 띄게 하는 거라 다른 기능을 써야한다.
.logos img{
height: 3.2rem;
filter: grayscale(100%);
}
brightness가 0이면 모든 로고가 검은색이 되고, 여기에 opacity를 추가하면 회색빛을 띈다.
.logos img{
height: 3.2rem;
filter: brightness(0);
opacity:50%;
}
blur, saturate, contrast, …
heroicon과 같은 사이트에서 svg 아이콘 코드를 복사해 html에 추가하면, 코드가 길어져 가독성이 떨어지고 이해하기 어려워진다.
이를 해결하기 위해 ionicons에서 아이콘 팩을 <script>
를 html의 body 끝에 붙여넣고, 아이콘 눌러 복사된 내용을 사용하면 된다.
<li class="meal-attribute">
<ion-icon name="flame-outline"></ion-icon>650 calories ❌
</li>
<li class="meal-attribute">
<ion-icon name="flame-outline"></ion-icon>
<span>650 calories</span>✅보기가 더 좋다.
</li>
icon을 제공하는 곳마다 어떤 곳은 색깔에 대해 stroke
를 쓸 수도 있고, fill
을 쓸 수도 있고, color
를 쓸 수도 있다.
글자 크기에 대해서는 height
, width
, font-size
등을 쓸 수 있다.
개발자 도구를 통해 확인해보는 습관을 가지자.
strong{
font-weight: 500;
}
카드를 만들 때 수직으로만 그림자를 주고,
blur는 수직 그림자 크기의 2배가 되도록 하면 편하다.
.meal{
/* offset-x | offset-y | blur-radius | color */
box-shadow: 0 2.4rem 4.8rem rgba(0,0,0,0.075);
}
.meal{
/* offset-x | offset-y | blur-radius | color */
box-shadow: 0 2.4rem 4.8rem rgba(0,0,0,0.075);
border-radius: 11px;
}
위와 같이 하면 meal 클래스 안에 있는 이미지의 끝은 여전히 뾰족하다.
이를 해결하기 위해 아래처럼 overflow: hidden
을 사용할 수 있다.
.meal{
/* offset-x | offset-y | blur-radius | color */
box-shadow: 0 2.4rem 4.8rem rgba(0,0,0,0.075);
border-radius: 11px;
overflow: hidden;
}
currentColor
를 사용하면 현재 텍스트 색깔과 동일한 색을 선택한다.:hover
, :active
에 색깔이 변하는 효과를 주면 border-bottom 색깔도 같이 변한다..link:link,.link:visited{
display: inline-block;
color: #e67e22;
text-decoration: none;
border-bottom: 1px solid currentColor;
padding-bottom: 2px;
}
border: none;
효과를 주면 1px 차이로 전체 레이아웃이 흔들린다.transparent
키워드를 사용할 수 있다..link:hover, .link:active{
color: #cf711f;
/* border-bottom: none; */
border-bottom: 1px solid transparent;
}
.meal{
box-shadow: 0 2.4rem 4.8rem rgba(0,0,0,0.075);
border-radius: 11px;
overflow: hidden;
transition: all 0.4s;
}
.meal:hover{
transform: translateY(-1.2rem); /* 위로 올라가면서 */
box-shadow: 0 3.2rem 6.4rem rgba(0,0,0,0.06); /* 빛에 가까워지므로 그림자는 더 커지도록 */
}
transition
은 항상 :original class에 써준다. :hover
에 써주면 안됨.<figure class="testimonials">
<img
class="testimonial-img"
alt="Photo of customer Dave Bryson"
src="img/customers/dave.jpg"
/>
<blockquote class="testimonial-text">
Inexpensive, healthy and great-tasting meals, without even having
to order manually! It feels truly magical.
</blockquote>
<p class="testimonial-name">—Dave Bryson</p>
</figure>
<figure>
: 사진 등이 함께 들어갈 때 자주 쓰인다.
—
: 이름 옆에 자주 쓰인다.
<figcaptuion>:
figure의 캡션으로 쓰인다. <figure>
태그 안에서만 쓰일 수 있다.
display:block;
을 설정해주면 해결할 수 있다.grid-template-columns: 55fr 45fr;
.gallery-item{
overflow: hidden;
}
.gallery-item img{
display:block;
width:100%;
transition: all 0.4s;
}
.gallery-item img:hover{
transform: scale(1.1);
}