font-family: 字體,一個頁面建議兩種字體就好
font-size: 字體大小
font-weight: 字體粗度
text-align: 置左/中/右
color: 字體顏色
background-color: 背景顏色
opacity: 字體透明度(0~1)
You can use the <link> element to link HTML and CSS files together. The <link> element must be placed within the head of the HTML file.
css優先順位:id > class > tag
id很難被覆寫,盡量不要用
p {} - tag
.cursive{} - class
#bold{} - id
.class tag{} - 只有這個class下的tag會被改變
tag.class{} - 這個tag有寫到class才會改變
!important - 不管其他語法如何,都不會被覆寫
一個tag裡可以有很多個class
<h5 class="bold cursive capitalize">
可以直接對content做長寬的設定,利用padding來做一個透明的box增加content和border的間距
border視覺化框框
padding: (top)px (right)px (bottom)px (left)px
padding: (top&bottom)px (right&left)px
padding-top: px
padding-bottom: px
padding-left: px
padding-right: px
margin(left/right)的值會相加
Element A:
margin-right: 10px
Element B:
margin-left: 10px
margin between A and B is 20px
margin(top/bottom)的值取大的
Element A:
margin-bottom: 10px
Element C:
margin-top: 30px
margin between A and c is 30px
an image that has the following dimensions is 364 pixels wide and 244 pixels tall.
margin: 0 auto horizontally centers an element inside of its parent content area, if it has a width.
The overflow property can be set to display, hide, or scroll, and dictates how HTML will render content that overflows its parent’s content area.
The visibility property can hide or show elements.
預設值實際的box長寬計算方式=content+padding+border
The default value of the box-sizing property is content-box.
如果在css開頭加這語法,content大小會自動調節,box長寬就會固定
The position property allows you to specify the position of an element in three different ways.
relative
an element’s position is relative to its default position on the page.
absolute
an element’s position is relative to its closest positioned parent element. It can be pinned to any part of the web page, but the element will still move with the rest of the document when the page is scrolled.
fixed
an element’s position can be pinned to any part of the web page. The element will remain in view no matter what.
z-index
an element specifies how far back or how far forward an element appears on the page when it overlaps other elements.
property allows you control how an element flows vertically and horizontally a document.
The float property can move elements as far left or as far right as possible on a web page.
You can clear an element’s left or right side (or both) using the clear property.
Hexadecimal is a number system with has sixteen digits, 0 to 9 followed by “A” to “F”.
Hex values always begin with # and specify values of red, blue and green using hexademical numbers such as #23F41A.
RGB colors use the rgb() syntax with one value for red, one value for blue and one value for green.
RGB values range from 0 to 255 and look like this: rgb(7, 210, 50).
HSL stands for hue (the color itself), saturation (the intensity of the color), and lightness (how light or dark a color is).
Hue ranges from 0 to 360 and saturation and lightness are both represented as percentages like this: hsl(200, 20%, 50%).
rgba(r, g, b, a=0~1)
hsla(hue, saturation, lightness, a=0~1)
可以透過font google增加字體(link比較快)
<link>
tag or the @font-face property.
<link href="font google提供的字體連結" type="text/css" rel="stylesheet">
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap')
word-spacing property changes how far apart individual words are.
letter-spacing property changes how far apart individual letters are.
text-align property changes the horizontal alignment of text.