CSS3邊框與背景

來源:互聯網
上載者:User

標籤:jks   ashx   sbo   pdo   qml   npos   tcp   rhcs   ifd   

參考:

http://www.runoob.com/css3/css3-tutorial.html

 

CSS3被拆分為"模組"。舊規範已拆分成小塊,還增加了新的。

一些最重要CSS3模組如下:

  • 選取器
  • 盒模型
  • 背景和邊框
  • 文字特效
  • 2D/3D轉換
  • 動畫
  • 多欄版面配置
  • 使用者介面

 1.CSS3邊框:

 

用 CSS3,你可以建立圓角邊框,添加陰影框,並作為邊界的形象而不使用設計程式,如 Photoshop。

 

在本章中,您將瞭解以下的邊框屬性:

 

  • border-radius
  • box-shadow
  • border-image

 

1.  圓角邊框

<style> div{    border:2px solid #a1a1a1;    padding:10px 40px;     background:#dddddd;    width:300px;    border-radius:25px;}</style></head><body><div>border-radius 屬性允許您為元素添加圓角邊框! </div>

 

 

2.陰影

div
{
    width:300px;
    height:100px;
    background-color:yellow;
    box-shadow: 10px 10px 5px #888888;
}

 

 

 

 

2.CSS3背景

 

CSS3中包含幾個新的背景屬性,提供更大背景元素控制。

在本章您將瞭解以下背景屬性:

  • background-image
  • background-size
  • background-origin
  • background-clip
background-image屬性

不同的背景映像和映像用逗號隔開,所有的圖片中顯示在最頂端的為第一張。

#example1 {    background-image: url(img_flwr.gif), url(paper.gif);    background-position: right bottom, left top;    background-repeat: no-repeat, repeat;    padding: 15px;}</style>

 

 

 CSS3 background-size 屬性

background-size指定背景映像的大小。CSS3以前,背景映像大小由映像的實際大小決定。

CSS3中可以指定背景圖片,讓我們重新在不同的環境中指定背景圖片的大小。您可以指定像素或百分比大小。

你指定的大小是相對於父元素的寬度和高度的百分比的大小。

body{    background:url(/try/demo_source/img_flwr.gif);    background-size:80px 60px;    background-repeat:no-repeat;    padding-top:40px;}

 

 

CSS3的background-Origin屬性

background-Origin屬性指定了背景映像的位置地區。

content-box, padding-box,和 border-box地區內可以放置背景映像。

div{    border:1px solid black;    padding:35px;    background-image:url(‘smiley.gif‘);    background-repeat:no-repeat;    background-position:left;}#div1{    background-origin:border-box;}#div2{    background-origin:content-box;}

 

 

 

 

 

CSS3 background-clip屬性

CSS3中background-clip背景剪裁屬性是從指定位置開始繪製

 

<!DOCTYPE html><html><head><meta charset="utf-8"> <title>菜鳥教程(runoob.com)</title> <style>#example1 {    border: 10px dotted black;    padding:35px;    background: yellow;}#example2 {    border: 10px dotted black;    padding:35px;    background: yellow;    background-clip: padding-box;}#example3 {    border: 10px dotted black;    padding:35px;    background: yellow;    background-clip: content-box;}</style></head><body><p>沒有背景剪裁 (border-box沒有定義):</p><div id="example1"><h2>Lorem Ipsum Dolor</h2><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p></div><p>background-clip: padding-box:</p><div id="example2"><h2>Lorem Ipsum Dolor</h2><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p></div><p>background-clip: content-box:</p><div id="example3"><h2>Lorem Ipsum Dolor</h2><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p></div></body></html>

 

 

 

 

 

CSS3邊框與背景

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.