常用的HTML5和CSS3標簽及用法(入門篇)


一、HTML5

1.標簽

  HTML5本質上只是增加了一些語義化標簽

  只兼容高版本(ie9以上)瀏覽器

  最有用的三個標簽:video 視頻

             audio 音頻

             canvas 畫圖板,替代flash(操作上比較困難)

  用處不大但很多時候又可以用到的一些標簽:

           header  頭部

           footer   尾部

           nav    導航

           aside   側邊欄

           section  模塊

2.表單里面新添加的一些html5屬性

<form>
<input type="email" /> 郵箱輸入,自帶錯誤提示(無法修改樣式)

  <input type="color" />    一個可以選擇顏色的調色板

   <input type="date" />    年月日下拉框 (在手機上顯示的時候,會有滑動的選擇,很好看)



<input type="month" /> 選擇月份下拉框

<input type="week" /> 周選擇下拉框


<input type="url" /> URL

<input type="tel" /> 調用手機數字鍵盤

<input type="search" />  搜索(帶個叉 可關

<input type="range" />  拖拽條

<input type="number" max="10" min="0" /> 有條件范圍的數字框

</form>

二、css3 (IE9以下不兼容 9部分兼容)

  1、盒子陰影  box-shadow:x   y   blur(模糊度)  spread(內擴充,相當於padding)   color   inset(內陰影);

     例 box-shadow:100px 100px 0px 100px #f00;  box-shadow:0px 0px 50px 0px #f00 inset; 

  2、文字陰影  text-shadow:x y blur color;

     例 text-shadow:1px 1px 1px #000;   div:hover{ text-shadow:1px 1px 1px #000; } 

  3、背景透明度  background:rgba(0,0,0,alpha)

     opacity 會把子級也透明,rgba只把背景色透明,所以推薦使用rgba

          opacity:0.1   透明度(ie8以上)

          低版本瀏覽器寫法:filter:alpha(opacity:50);

  4、背景圖大小  background-size : width height;

     使用background-size,要不cover等比縮放,要不寫死(會導致圖片拉伸,變形),無法同時定義圖片的寬高又讓其等比縮放。

  5、background:url(),url();     多個背景圖

div{ width:800px; height:600px; background:url(../img/2.jpg) no-repeat,url(../img/2.jpeg) no-repeat center; background-size:200px 200px; border:1px solid red; }

 

  6、圓角  border-radius  可以使用像素也可以使用百分比

      一個值:四個方向
      兩個值:左上右下 右上左下
      三個值:左上 右上左下 右下
      四個值:左上 右上 右下 左下(順時針)

  7、過渡  transition:1s 時間    樣式(all 所有樣式)  運動類型  寫的值不分順序

      linear勻速     ease先加后減(緩沖)     ease-in加速      ease-out減速

  8、瀏覽器前綴

    (transition會涉及到瀏覽器前綴)

      -webkit- 谷歌瀏覽器

      -moz- 火狐瀏覽器

      -ms- IE瀏覽器

      -o- 歐朋

  9、漸變色 

    線性漸變background-image:-webkit-linear-gradient(方向left top,color起始顏色,color結束顏色);

    重復漸變background-image:-webkit-repeating-linear-gradient(left top,clolr,color);

  10、文字描邊

    -webkit-text-stroke:描邊大小 color; -webkit-text-stroke:2px red; 

  11、css3動畫:

    animation:time時間,name名字,ease類型,infinite重復運動

 

    @keyframes name{

      to{}

      from{}

      0%{}

      100%{}

    }

1 <style>
2 @keyframes test{
3     to{ left:300px; }
4     from{ left:0; }
5 }
6 div{ width:200px; height:200px; background:red; animation:test ease 1s infinite; position:absolute; left:0; top:0 }
7 </style>
1 <style>
2 @keyframes test{
3     0%{ left:0px; }
4     50%{ top:200px; }
5     100%{ left:300px; }
6 }
7 div{ width:200px; height:200px; background:red; animation:test ease 1s infinite; position:absolute; left:0; top:0 }
8 </style>

 

  12、倒影

  -webkit-box-reflect:below 10px -webkit-linear-gradient(rgba(0,0,0,0) 50%,rgba(0,0,0,1))

  below向下 above向上 left right

  13、濾鏡  -webkit-filter:blur(0px 模糊度);

  14、變形

 transform:
translate(x,y) 移動px
rotate() 旋轉deg
skew(x,y) 傾斜deg
scale(x,y) 放大比例
transform:transform(x,y) rotate() skew(x,y) scale(x,y);
從后往前執行


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM