Css初始化Readme文件
以下提供两种方法,请选择合适自己的,且根据项目实际需求自行修改
方法一:引用Github中necolas的浏览器初始化
该方法的目的为:消除不同浏览器对HTML文本呈现的差异.
代码演示
html { line-height: 1.15; -webkit-text-size-adjust: 100%; }
body { margin: 0; }
main { display: block; }
h1 { font-size: 2em; margin: 0.67em 0; }
hr { box-sizing: content-box; height: 0; overflow: visible; }
pre { font-family: monospace, monospace; font-size: 1em; }
a { background-color: transparent; }
abbr[title] { border-bottom: none; text-decoration: underline; text-decoration: underline dotted; }
b, strong { font-weight: bolder; }
code, kbd, samp { font-family: monospace, monospace; font-size: 1em; }
small { font-size: 80%; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sub { bottom: -0.25em; } sup { top: -0.5em; }
img { border-style: none; }
button, input, optgroup, select, textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0; }
button, input { overflow: visible; }
button, select { text-transform: none; }
button, [type="button"], [type="reset"], [type="submit"] { -webkit-appearance: button; }
button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner { border-style: none; padding: 0; }
button:-moz-focusring, [type="button"]:-moz-focusring, [type="reset"]:-moz-focusring, [type="submit"]:-moz-focusring { outline: 1px dotted ButtonText; }
fieldset { padding: 0.35em 0.75em 0.625em; }
legend { box-sizing: border-box; color: inherit; display: table; max-width: 100%; padding: 0; white-space: normal; }
progress { vertical-align: baseline; }
textarea { overflow: auto; }
[type="checkbox"], [type="radio"] { box-sizing: border-box; padding: 0; }
[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button { height: auto; }
[type="search"] { -webkit-appearance: textfield; outline-offset: -2px; }
[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
::-webkit-file-upload-button { -webkit-appearance: button; font: inherit; }
details { display: block; }
summary { display: list-item; }
template { display: none; }
[hidden] { display: none; }
|
方式二:常用标签的初始化
该方法的目的为:一般标签在浏览器中都有默认样式,例如body标签有默认的外边距,ul有默认的小黑点和内边距,前端程序员在写页面的时候会把这些默认的样式都清除掉,让所有标签的外观效果在所有浏览器表现一致,这个步骤就是css的初始化。
代码演示
HTML, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, blockquote, pre, form, fieldset, table, th, td { border:none; font-family:"微软雅黑","黑体","宋体"; font-size:14px; margin:0px; padding:0px; } html,body{ height: 100%; width: 100%; } address, caption, cite, code, dfn, em, strong, th, var { font-style: normal; font-weight: normal; } a{ text-decoration:none; } a:link{ color:#fff; } a:visited{ color:#fff; } a:hover{ color:#fff; } a:active{ color:#fff; } input::-ms-clear{ display:none; } input::-ms-reveal{ display:none; } input{ -webkit-appearance: none; margin: 0; outline: none; padding: 0; } input::-webkit-input-placeholder{ color: #ccc; } input::-ms-input-placeholder{ color: #ccc; } input::-moz-placeholder{ color: #ccc; } input[type=submit],input[type=button]{ cursor: pointer; } button[disabled], input[disabled] { cursor: default; } img{ border:none; } ul,ol,li{ list-style-type:none; }
.clear{ clear: both; } .clearleft{ clear: left; } .clearright{ clear: right; } .floatleft{ float: left; } .floatright{ float: right; } .cursor{ cursor: pointer; }
.bg000{ background: #000; } .color000{ color: #000; }
|
调用实现
在项目HTML头文件中声明该文件的地址,注意路径是否正确
调用代码演示
<!DOCTYPE html> <html lang="EN"> <head> <meta charset="UTF-8"> <title>标题</title> <link rel="stylesheet" href="./readne.css"> </head> </html>
|
版權聲明: 此文章版權歸Arvin所有,如有轉載,請註明來自原作者