Web開發(初級)- CSS基礎

來源:互聯網
上載者:User

標籤:css

CSS概述

css是英文Cascading Style Sheets的縮寫,稱為層疊樣式表,用於對頁面進行美化。


存在方式有三種:元素內聯、頁面嵌入和外部引入:

 文法:style=‘key1:value1;key2:value2;‘

  • 在標籤中使用 style=‘xx:xxx;‘

  • 在頁面中嵌入 <style type="text/css"> </style> 塊

  • 引入外部css檔案<link rel="stylesheet" type="text/css" href="css/common.css" >

 必要性:美工會對頁面的色彩搭配和圖片的美化負責,開發人員則必須知道是如何?的。


各種選取器標籤選取器
div{ background-color:red; } <div> </div>
class選取器
.bd{ background-color:red; } <div class=‘bd‘> </div>
id選取器
#idselect{ background-color:red; } <div id=‘idselect‘> </div>
關聯選取器
#idselect p{ background-color:red; } <div id=‘idselect‘> <p> </p> </div>
組合選取器
input, div, p{ background-color:red; }
屬性選取器
input[type=‘text‘]{ width:100px; height:200px; }

更多

CSS常用屬性background
  • background-color 

  • background-image

  • background-repeat(no-repeat;repeat-x;repeat-y)

  • background-position

border
<div style="border:1px solid red; height: 10px;"></div>    /* 實體框 */<div style="border:1px dotted red; height: 10px;"></div>    /* 點點框 */<div style="border:1px dashed red; height: 10px;"></div>    /* 虛線框 */

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M00/89/D1/wKioL1ge2srjfMEiAAACzT4i4qM291.png" title="solid.png" alt="wKioL1ge2srjfMEiAAACzT4i4qM291.png" />

margin
<div style="border:1px solid red; height:70px; width:500px">    <div style="background-color: green; height: 50px; margin-top:20px;"></div></div>

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/89/D4/wKiom1ge3CGw7nzpAAAB2NZ3xhk234.png" title="margin.png" alt="wKiom1ge3CGw7nzpAAAB2NZ3xhk234.png" />

padding
<div style="border:1px solid red; height: 70px; width:500px">    <div style="background-color: green; height: 50px; padding-top: 20px;"></div></div>

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M00/89/D1/wKioL1ge3G3TUvGiAAAB7F-ie4A386.png" title="padding.png" alt="wKioL1ge3G3TUvGiAAAB7F-ie4A386.png" />

display
  • display:none;    /* 連同位置一起隱藏 */

  • display:block;

  • display:inline;

visibility
  • visibility:hidden;    /* 內容隱藏,但位置還在 */

  • visibility:visible;

cursor
<ul>    <li>css提供的cursor值</li>    <p>        <span style="cursor:pointer;">pointer</span> ||        <span style="cursor:help;">help</span> ||        <span style="cursor:wait;">wait</span> ||        <span style="cursor:move;">move</span> ||        <span style="cursor:crosshair;">crosshair</span>    </p>    <li>偽造超連結</li>    <p>        <span style="cursor:pointer;color:blue;">pointer</span>    </p>    <li>自訂(一般不用)</li>    <p>        <span style="cursor:url(image/favicon.ico),auto;">mine</span>    </p></ul>
浮動
<div style="background-color: red;">    <div style="background-color:green; float:left">left</div>    <div style="background-color:blue; float:right">right</div>    <div style="clear:both;"></div>    /* 將漂浮的標籤拽下來,撐起父標籤,要不父標籤就看不見了 */</div>
position

講得不錯

透明度

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/89/D1/wKioL1ge303QA1tIAAFxnsBTikE480.png" title="6.png" alt="wKioL1ge303QA1tIAAFxnsBTikE480.png" />


Web開發(初級)- CSS基礎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.