總結CSS提示

來源:互聯網
上載者:User
使用 line-height 垂直置中

line-height:24px;
使用固定寬度的容器並且需要一行垂直置中時,使用 line-height 即可(高度與父層容器一致),更多的垂直置中總結可以看這裡。

清除容器浮動

#main { overflow:hidden; }

期前也提到過這樣的問題,更多資訊可以看這裡。

不讓連結折行

a { white-space:nowrap; }

上面的設定就能避免連結折行,不過個人建議長連結會有相應的這行(有關換行方面的討論,參看圓心的記錄)。

始終讓 Firefox 顯示捲軸

html { overflow:-moz-scrollbars-vertical; }

更多的 Mozilla/Firefox 私人 CSS 屬性可以參考這裡。需跨瀏覽器的支援,也可以使用

body, html { min-height:101%; }

使塊元素水平置中

margin:0 auto;
其實就是

margin-left: auto;
margin-right: auto;
這個技巧基本上所有的 CSS 教科書都會有說明,別忘記給它加上個寬度。Exploer 下也可以使用

body{ text-align: center; }

然後定義內層容器

text-align: left;
恢複。

隱藏 Exploer textarea 的捲軸

textarea { overflow:auto; }

Exploer 預設情況下 textarea 會有垂直捲軸(不要問我為什麼)。

設定列印分頁

h2 { page-break-before:always; }

page-break-before 屬效能設定列印網頁時的分頁。

刪除連結上的虛線框

a:active, a:focus { outline:none; }

Firefox 預設會在連結獲得焦點(或者點擊時)加上條虛線框,使用上面的屬性可以刪除。

最簡單的 CSS 重設

* { margin: 0; padding: 0 }
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.