JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<h1>Big Letter</h1>
<p id="id" class="class"> Good morning!(id) </p>
<p id="id1"> Good morning!(id1) </p>
<p id="id2"> Good Afternoon!(id2) <span id="free"> FREE ! </span></p>
<p id="id3"> Good Night!(id3) </p>
</body>
CSS
p{
font-size: 14px;
}
/* 셀렉터 우선 순위 규칙
1. 뒤에 선언된 게 우선시 된다.
2. class보다 id 가 우선시 된다.
3. 상세하게 지정한 것이 우선시 된다.(부모요소까지 자세하게 지정해 준 것)
4. !important 우선순위 무시하고 !important 지정한 것을 우선으로 스타이 지정.
*/
#id {
color: red;
/* color: red !important; 라고 쓰면 이 스타일로 지정(우선순위 무시) */
}
#id {
color: green;
}
/* 이런 식으로 중복해서 지정하면 뒤에 선언한 스타일이 적용됨.*/
/*-------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------*/
/* 요소의 포지션 지정하기
position: static, relative, absolute, fixed
*/
#id3{
position: relative;
color: white;
left: 30px;
top: 30px;
background-color: blue;
}
/* relative 는 원래 있어야 할 위치로부터의 상대적인 위치를 지정. */
#id2{
position: relative;
background-color: red;
}
#free{
position: absolute;
top: -10px;
left: 50px;
background-color: yellow;
}
/* absolute는 부모요소(id2)가 relative로 지정 되어 있을 때 자식 요소(free)의 위치를 지정하기 위해 사용 */
#id1{
position: fixed;
bottom: 0;
background-color: gray;
}
/* 요소의 절대 위치를 지정해준다. */