(CSS Tools: Reset CSS)[https://meyerweb.com/eric/tools/css/reset/]
手刻網站的情境,最怕的就是遇到很多瀏覽器的樣式不統一很難去統一化所以會先執行以下的方式
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
往下添加這是我常用的兩個預設功能:
box-sizing: border-box;
將 Box-Model 寬度計算至包含border
的寬度margin: 0 auto;
置中的方式之一
* {
box-sizing: border-box;
}
body {
margin: 0 auto;
}
使用 Reset CSS 後,前端Web又有分幾種類型:
- 以手切為主的網站 多數需要
float
- 套版網站的卡片形網站直接使用 Bootstarp 去修改 (非常快速)
- 只需要
flex
功能的就可以直接套用下方的CSS(不一定要使用)
@media (min-width: 576px) {
.container {
max-width: 540px;
}
}
@media (min-width: 768px) {
.container {
max-width: 720px;
}
}
@media (min-width: 992px) {
.container {
max-width: 960px;
}
}
@media (min-width: 1200px) {
.container {
max-width: 1140px;
}
}
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin: 0 auto;
padding: 0 15px;
border: 1px solid black;
}
.row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-right: -15px;
margin-left: -15px;
}
.col {
flex-basis: 0;
flex-grow: 1;
max-width: 100%;
}