国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
css使用技巧

1. 文字的水平居中

將一段文字置于容器的水平中點(diǎn),只要設(shè)置text-align屬性即可:

  text-align:center;

2. 容器的水平居中

先為該容器設(shè)置一個(gè)明確寬度,然后將margin的水平值設(shè)為auto即可。

  div#container {
    width:760px;
    margin:0 auto;
  }

3. 文字的垂直居中

單行文字的垂直居中,只要將行高與容器高設(shè)為相等即可。

比如,容器中有一行數(shù)字。

  <div id="container">1234567890</div>

然后CSS這樣寫(xiě):

  div#container {height: 35px; line-height: 35px;}

如果有n行文字,那么將行高設(shè)為容器高度的n分之一即可。

4. 容器的垂直居中

比如,有一大一小兩個(gè)容器,請(qǐng)問(wèn)如何將小容器垂直居中?

  <div id="big">
    <div id="small">
    </div>
  </div>

首先,將大容器的定位為relative。

  div#big{
    position:relative;
    height:480px;
  }

然后,將小容器定位為absolute,再將它的左上角沿y軸下移50%,最后將它margin-top上移本身高度的50%即可。

  div#small {
    position: absolute;
    top: 50%;
    height: 240px;
    margin-top: -120px;
  }

使用同樣的思路,也可以做出水平居中的效果。

5. 圖片寬度的自適應(yīng)

如何使得較大的圖片,能夠自動(dòng)適應(yīng)小容器的寬度?CSS可以這樣寫(xiě):

  img {max-width: 100%}

但是IE6不支持max-width,所以遇到IE6時(shí),使用IE條件注釋,將語(yǔ)句改寫(xiě)為:

  img {width: 100%}

6. 3D按鈕

要使按鈕具有3D效果,只要將它的左上部邊框設(shè)為淺色,右下部邊框設(shè)為深色即可。

  div#button {
    background: #888;
    border: 1px solid;
    border-color: #999 #777 #777 #999;
  }

7. font屬性的快捷寫(xiě)法

font快捷寫(xiě)法的格式為:

  body {
    font: font-style font-variant font-weight font-size line-height font-family;
  }

所以,

  body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: normal;
    font-variant: small-caps;
    font-style: italic;
    line-height: 150%;
  }

可以被寫(xiě)成:

  body {
    font: italic small-caps normal 13px/150% Arial, Helvetica, sans-serif;
  }

8. link狀態(tài)的設(shè)置順序

link的四種狀態(tài),需要按照下面的前后順序進(jìn)行設(shè)置:

  a:link
  a:visited
  a:hover
  a:active

9. IE條件注釋

你可以利用條件注釋?zhuān)O(shè)置只對(duì)IE產(chǎn)生作用的語(yǔ)句:

  <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="ie-stylesheet.css" />
  < ![endif]-->

還可以區(qū)分各種不同的IE版本:

  <!--[if IE 6]> - targets IE6 only -->
  <!--[if gt IE 6]> - targets IE7 and above -->
  <!--[if lt IE 6]> - targets IE5.5 and below -->
  <!--[if gte IE 6]> - targets IE6 and above -->
  <!--[if lte IE 6]> - targets IE6 and below -->

10. IE6專(zhuān)用語(yǔ)句:方法一

由于IE6不把html視為文檔的根元素,所以利用這一點(diǎn),可以寫(xiě)出只有IE6才能讀到的語(yǔ)句:

  /* the following rules apply only to IE6 */

  * html{
  }

  * html body{
  }

  * html .foo{
  }

IE7專(zhuān)用語(yǔ)句則要寫(xiě)成

  /* the following rules apply only to IE7 */

  *+html .foo{
  }

11. IE專(zhuān)用語(yǔ)句:方法二

除了IE6以外,所有瀏覽器都不能識(shí)別屬性前的下劃線(xiàn)。而除了IE7之外,所有瀏覽器都不能識(shí)別屬性前的*號(hào),因此可以寫(xiě)出只有這兩個(gè)瀏覽器才能讀到的語(yǔ)句:

  .element {
    background: red; /* modern browsers */
    *background: green; /* IE 7 and below */
    _background: blue; /* IE6 exclusively */
  }

12. CSS的優(yōu)先性

如果同一個(gè)容器被多條CSS語(yǔ)句定義,那么哪一個(gè)定義優(yōu)先呢?

基本規(guī)則是:

  行內(nèi)樣式 > id樣式 > class樣式 > 標(biāo)簽名樣式

比如,有一個(gè)元素:

  <div id="ID" class="CLASS" style="color:black;"></div>

行內(nèi)樣式是最優(yōu)先的,然后其他設(shè)置的優(yōu)先性,從低到高依次為:

  div < .class < div.class < #id < div#id < #id.class < div#id.class

13. IE6的min-height

IE6不支持min-height,有兩種方法可以解決這個(gè)問(wèn)題:

方法一:

  .element {
    min-height: 500px;
    height: auto !important;
    height: 500px;
  }

共有三條CSS語(yǔ)句,第一句是針對(duì)其他瀏覽器設(shè)置最小高度,第三句是針對(duì)IE設(shè)置最小高度,第二句則是讓其他瀏覽器覆蓋第三句的設(shè)置。

方法二:

  .element {
    min-height: 500px
    _height: 500px
  }

_height只有IE6能讀取。

14. font-size基準(zhǔn)

瀏覽器的缺省字體大小是16px,你可以先將基準(zhǔn)字體大小設(shè)為10px:

  body {font-size:62.5%;}

后面統(tǒng)一采用em作為字體單位,2.4em就表示24px。

  h1 {font-size: 2.4 em}

15. Text-transform和Font Variant

Text-transform用于將所有字母變成小寫(xiě)字母、大寫(xiě)字母或首字母大寫(xiě):

  p {text-transform: uppercase}
  p {text-transform: lowercase}
  p {text-transform: capitalize}

Font Variant用于將字體變成小型的大寫(xiě)字母(即與小寫(xiě)字母等高的大寫(xiě)字母)。

  p {font-variant: small-caps}

16. CSS重置

CSS重置用于取消瀏覽器的內(nèi)置樣式,請(qǐng)參考YUIEric Meyer的樣式表。

17. 用圖片充當(dāng)列表標(biāo)志

默認(rèn)情況下,瀏覽器使用一個(gè)黑圓圈作為列表標(biāo)志,可以用圖片取代它:

  ul {list-style: none}

  ul li {
    background-image: url("path-to-your-image");
    background-repeat: none;
    background-position: 0 0.5em;
  }

18. 透明

將一個(gè)容器設(shè)為透明,可以使用下面的代碼:

  .element {
    filter:alpha(opacity=50);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5;
  }

在這四行CSS語(yǔ)句中,第一行是IE專(zhuān)用的,第二行用于Firefox,第三行用于webkit核心的瀏覽器,第四行用于Opera。

19. CSS三角形

如何使用CSS生成一個(gè)三角形?

先編寫(xiě)一個(gè)空元素

  <div class="triangle"></div>

然后,將它四個(gè)邊框中的三個(gè)邊框設(shè)為透明,剩下一個(gè)設(shè)為可見(jiàn),就可以生成三角形效果:

  .triangle {
    border-color: transparent transparent green transparent;
    border-style: solid;
    border-width: 0px 300px 300px 300px;
    height: 0px;
    width: 0px;
  }

20. 禁止自動(dòng)換行

如果你希望文字在一行中顯示完成,不要自動(dòng)換行,CSS命令如下:

  h1 { white-space:nowrap; }

21. 用圖片替換文字

有時(shí)我們需要在標(biāo)題欄中使用圖片,但是又必須保證搜索引擎能夠讀到標(biāo)題,CSS語(yǔ)句可以這樣寫(xiě):

  h1 {
    text-indent:-9999px;
    background:url("h1-image.jpg") no-repeat;
    width:200px;
    height:50px;
  }

22. 獲得焦點(diǎn)的表單元素

當(dāng)一個(gè)表單元素獲得焦點(diǎn)時(shí),可以將其突出顯示:

  input:focus { border: 2px solid green; }

23. !important規(guī)則

多條CSS語(yǔ)句互相沖突時(shí),具有!important的語(yǔ)句將覆蓋其他語(yǔ)句。由于IE不支持!important,所以也可以利用它區(qū)分不同的瀏覽器。

  h1 {
    color: red !important;
    color: blue;
  }

上面這段語(yǔ)句的結(jié)果是,其他瀏覽器都顯示紅色標(biāo)題,只有IE顯示藍(lán)色標(biāo)題。

24. CSS提示框

當(dāng)鼠標(biāo)移動(dòng)到鏈接上方,會(huì)自動(dòng)出現(xiàn)一個(gè)提示框。

  <a class="tooltip" href="#">鏈接文字 <span>提示文字</span></a>

CSS這樣寫(xiě):

  a.tooltip {position: relative}
  a.tooltip span {display:none; padding:5px; width:200px;}
  a:hover {background:#fff;} /*background-color is a must for IE6*/
  a.tooltip:hover span{display:inline; position:absolute;}

25. 固定位置的頁(yè)首

當(dāng)頁(yè)面滾動(dòng)時(shí),有時(shí)需要頁(yè)首在位置固定不變,CSS語(yǔ)句可以這樣寫(xiě),效果參見(jiàn)http://limpid.nl/lab/css/fixed/header

  body{ margin:0;padding:100px 0 0 0;}

  div#header{
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:<length>;
  }

  @media screen{
    body>div#header{position: fixed;}
  }

  * html body{overflow:hidden;}

  * html div#content{height:100%;overflow:auto;}

IE6的另一種寫(xiě)法(用于固定位置的頁(yè)腳):

  * html #footer {
    position:absolute;
    top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}

26. 在IE6中設(shè)置PNG圖片的透明效果

  .classname {

    background: url(image.png);

    _background: none;

    _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
        (src='image.png', sizingMethod='crop');

  }

27. 各類(lèi)瀏覽器的專(zhuān)用語(yǔ)句

  /* IE6 and below */
  * html #uno { color: red }

  /* IE7 */
  *:first-child+html #dos { color: red }

  /* IE7, FF, Saf, Opera */
  html>body #tres { color: red }

  /* IE8, FF, Saf, Opera (Everything but IE 6,7) */
  html>/**/body #cuatro { color: red }

  /* Opera 9.27 and below, safari 2 */
  html:first-child #cinco { color: red }

  /* Safari 2-3 */
  html[xmlns*=""] body:last-child #seis { color: red }

  /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
  body:nth-of-type(1) #siete { color: red }

  /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
  body:first-of-type #ocho { color: red }

  /* saf3+, chrome1+ */
  @media screen and (-webkit-min-device-pixel-ratio:0) {
    #diez { color: red }
  }

  /* iPhone / mobile webkit */
  @media screen and (max-device-width: 480px) {
    #veintiseis { color: red }
  }

  /* Safari 2 - 3.1 */
  html[xmlns*=""]:root #trece { color: red }

  /* Safari 2 - 3.1, Opera 9.25 */
  *|html[xmlns*=""] #catorce { color: red }

  /* Everything but IE6-8 */
  :root *> #quince { color: red }

  /* IE7 */
  *+html #dieciocho { color: red }

  /* Firefox only. 1+ */
  #veinticuatro, x:-moz-any-link { color: red }

  /* Firefox 3.0+ */
  #veinticinco, x:-moz-any-link, x:default { color: red }

  /***** Attribute Hacks ******/

  /* IE6 */
  #once { _color: blue }

  /* IE6, IE7 */
  #doce { *color: blue; /* or #color: blue */ }

  /* Everything but IE6 */
  #diecisiete { color/**/: blue }

  /* IE6, IE7, IE8 */
  #diecinueve { color: blue\9; }

  /* IE7, IE8 */
  #veinte { color/*\**/: blue\9; }

  /* IE6, IE7 -- acts as an !important */
  #veintesiete { color: blue !ie; } /* string after ! can be anything */

28. 容器的水平和垂直居中

HTML代碼如下:

  <figure class='logo'>

    <span></span>

    <img class='photo'/>

  </figure>

CSS代碼如下:

  .logo {
    display: block;
    text-align: center;
    display: block;
    text-align: center;
    vertical-align: middle;
    border: 4px solid #dddddd;
    padding: 4px;
    height: 74px;
    width: 74px; }

  .logo * {
    display: inline-block;
    height: 100%;
    vertical-align: middle; }

  .logo .photo {
    height: auto;
    width: auto;
    max-width: 100%;
    max-height: 100%; }

29. CSS陰影

外陰影:

  .shadow {
    -moz-box-shadow: 5px 5px 5px #ccc;
    -webkit-box-shadow: 5px 5px 5px #ccc;
    box-shadow: 5px 5px 5px #ccc;
  }

內(nèi)陰影:

  .shadow {
    -moz-box-shadow:inset 0 0 10px #000000;
    -webkit-box-shadow:inset 0 0 10px #000000;
    box-shadow:inset 0 0 10px #000000;
  }

30. 取消IE文本框的滾動(dòng)條

  textarea { overflow: auto; }

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
30個(gè)開(kāi)發(fā)人員有用的CSS代碼片段
70多個(gè)非常實(shí)用的CSS小技巧
非常有用的CSS模板
Div+CSS樣式布局學(xué)習(xí)筆記(1)
IE 7,IE6,mozilla 瀏覽器的一些兼容問(wèn)題
CSS的inherit與auto ,有width和height的
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服