CSS Flashcards
선택자
* 전체 선택자 p 타입 선택자 . 클래스 선택자 # id 선택자
css 특징
- 스타일 우선순위
-> 타입<클래스<아이디<인라인<!important - 스타일 상속
-> 부모 스타일이 자식 스타일에도 적용 - 순서
-> 중요도, 명시도 동일 시 맨 나중 순서가 발현
글자 관련된 css
font-family: 1ststyle "2nd style" 3rdstyle; 1->3 순서로 적용됨 띄어쓰기 있는 font이름이면 ""사용 font-size: em/px/%/xx-small/x-small/small/medium/large/x-large/xx-large font-style: normal/italic/oblique; font-weight: normal/bold/bolder/lighter/heavy/100~900 text-align: start/end/left/right/center/justify/match-parent; text-decoration: none/underline/overline/line-through text-shadow: 가로거리 세로거리 번짐정도 색상; text-transform: capitalize/uppercase/lowercase/full-width; letter-spacing: word-spacing: line-height:
리스트 관련 css
list-style-type: disc/circle/square/decimal/decimal-leading-zero/lower-roman/upper-roman/lower-alpha/upper-alpha/none list-style-image: <url()> list-style-position: inside(들여쓰기)/outside list: 타입 포지션
표 관련 css
<table>태그에 달린 border-collapse: collapse/separate; caption-side: top/bottom
Css와 박스 모델
inline: 줄을 차지하지 않고 화면에 표시되는 콘텐츠만큼만 영역 차지해서 나머지 공간에 다른 요소 들어옴… 높이와 넓이 specified안됨
block: 요소를 삽입했을때 혼자 한 줄 차지… 높이와 넓이 specify됨
inline-block: 인라인과 블럭 합친 특징 가짐… 서로 옆에 나열 가능하지만 블럭처럼 생김…. 높이와 넓이 sepcify됨
양파껍질 같은 css
content: 그림
padding: 액자와 그림 사이의 공백.. background color을 확장하거나
border: 액자
margin: 우리 주인 건들지마!
content관련 속성
width:
height: %/em/px/auto(콘텐츠 양에 따라 자동결정)
padding관련 속성
padding/padding-top/padding-bottom/padding-left/padding-right:
2 value: topbottom leftright
3 value: top leftright bottom
4 value: top right bottom left
border관련 속성
border-style: none/hidden/solid/dashed/dotted/double/groove/inset/outset/ridge/solid border-width: px/%/thin/medium/thick border-color: border: 두께 스타일 색깔; border-top border-bottom border-left border-right border-radius: %/px/em; border-top-left-radius border-top-right-radius border-bottom-left-radius border-bottom-right-radius circle => height=width, border-radius=50%;
margin 관련 속성
margin으로 가운데 정렬하기
1. 매치할 요소의 너비값을 정해준다
2. margin-left와 margin-right 속성값을auto로 정해준다.
margin
margin-left
margin-right
margin-top
margin-bottom
left and right margin and padding add together
top and bottom padding add together
top and bottom margin collapse
전반적 박스 css 명령어
box-sizing: border-box/content-box;
(테두리까지 포함해서 너비값을 지정하기/콘텐츠 영역 너미값으로 지정하기)
box-shadow: 수평거리 수직거리 흐림정도 번짐정도 색상 inset
position: static/relative/aboslute(다른 요소들이 이 요소를 무시하고 가장 가까운 부모와 위치를 연동하기)/fixed/sticky(가만히 있다가 일정 부위를 지나면 움직이기)
left/right/top/bottom으로 offset 가능하다. (static만 아니라면)
z-index: 1/2/….
유니티의 layer과 같은 개념(누가 위에 오는가)
does not work on static elements
숫자가 클수록 앞으로 간다.
display: inline/block/inline-block
float: left/right/none;
clear: left/right/both/none;
background 관련 css
background-color:
background-image: url(파일경로);
background-size:
auto/contain/cover/px/em/%
background-repeat: repeat/repeat-x/repeat-y/no-repeat
background-position: 수평위치 수직위치
background-origin: border-box/padding-box/content-box
background-attachment: scroll/fixed;
background: 위의 모든 background 요소 연달아서 표기, 순서 상관 없음
background: linear-gradient( to 방향/각도, 색상 색상중지점,….)
방향: right bottom, right top, left bottom, left top
각도: deg
background: radial-gradient (eclipse*/circle 크기 at 위치, 색상 색상중지점)
closert-side/closest-corner/farthest-side/farthest-corner*
background: repeating-linear-gradient (yellow, yellow 20px, red 20px)
연결 선택자(combination selector)
선택자와 선택자를 연결시켜서 적용 대상을 제한하는 선택자.
1. 하위 선택자 (descendent selector)
상위요소 (space) 하위요소
->직속 자식이 아니어도 해당됨.
- 자식 선택자 (child selector)
상위요소 > 하위요소
-> 직속 자식만 해당됨. - 인접 형제 선택자 (adjacent selector)
같은 부모를 가진 형제 요소 중 첫번쨰 동생 요소에만 스타일 적용
요소1 + 요소2
e) h1 + p {} -> h1과 형제인 p 중 첫번째 p 요소만 적용 - 형제 선택자 (sibiling selector)
형제 요소 모두에게 스타일 적용
요소1~요소2
e) h1~p {} -> h1의 형제인 모든 p 요소에 스타일 적용.
속성 선택자
특정 속성을 가지고 있는 태그를 찾아서 스타일을 적용해주는 방식의 태그
1. tag [속성]
지정한 속성을 가진 요소를 찾아 스타일 적용
```a[href] {}
<li><a>메뉴1</a></li>
<li><a>메뉴2</a></li>
```
- tag[속성=” “]
주어진 속성과 속성값이 일치하는 요소를 찾아 스타일 적용
```a[target=”_blank”]{}
<li><a>HTML</a></li>
<li><a>CSS</a></li>
```
중에 위에꺼만 적용
- [속성~”속성값”]
해당 속성을 가지고 있고, 여러 속성값 중에 해당 속성값을 포함하는 애한테 스타일 적용
e) [class ~ “button”]{}
<li><a></a></li>
3.