當前位置:編程學習大全網 - 源碼下載 - body跟瀏覽器之間為什麽有邊距呀?

body跟瀏覽器之間為什麽有邊距呀?

① 這個是默認有的外邊距margin,甚至還有內邊距padding,比如Chrome有8px的margin外邊距;

② 操作,所以壹般要進行CSS樣式初始化,其中就有設置margin:0;padding:0;這樣,

(最簡便的寫法,但是不太建議)

* {

margin:0;

padding: 0;

}

③ 具體的初始化還有更多,可以參考壹下壹些大型網站的,查看網頁源代碼即可;

下面就有壹個我收藏整理的初始化樣式表,以後使用CSS時就先引入它,

初始化的樣式表壹般要寫在第壹個link標簽上,先引入嘛。

/*

要初始化的樣式有:

1. padding、margin都是0;

2. 鏈接標簽 a 的下劃線 text-decoration樣式要去除,還有 color字體顏色;

3. ul、ol、li標簽的list-style 黑點等要去除;

4. 整個body的字體類型font-family、html的字體大小font-size,後面的元素字體參照html的rem來設置font-size;

*/

blockquote,

body,

button,

dd,

dl,

dt,

fieldset,

form,

h1,

h2,

h3,

h4,

h5,

h6,

hr,

input,

legend,

li,

ol,

p,

pre,

td,

textarea,

th,

ul {

margin: 0;

padding: 0;

}

body,

button,

input,

select,

textarea {

font: 12px/1.5 "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;

font-size: 17px;

}

h1,

h2,

h3,

h4,

h5,

h6 {

font-size: 100%

}

address,

cite,

dfn,

em,

var {

font-style: normal

}

code,

kbd,

pre,

samp {

font-family: courier new, courier, monospace;

}

small {

font-size: 12px;

}

ol,

ul {

list-style: none;

}

a {

text-decoration: none;

color: black;

-webkit-tap-highlight-color: transparent;

/*清除點擊鏈接標簽a時出現的高亮背景色*/

}

sup {

vertical-align: text-top

}

sub {

vertical-align: text-bottom

}

legend {

color: #000

}

fieldset,

img {

border: 0

}

button,

input,

select,

textarea {

font-size: 100%

border: none;

outline: none;

}

button {

border-radius: 0

}

table {

border-collapse: collapse;

border-spacing: 0

}

  • 上一篇:並發框架源代碼大全
  • 下一篇:django是做什麽的?
  • copyright 2024編程學習大全網