CSS3 文字效果(陰影)

來源:互聯網
上載者:User

標籤:ack   tmg   ges   map   zrc   btn   rhn   bsd   tts   

CSS3中包含幾個新的文本特徵。

在本章中您將瞭解以下文字屬性:

  • text-shadow
  • box-shadow
  • text-overflow
  • word-wrap
  • word-break

 

CSS3 的文本陰影

CSS3 中,text-shadow屬性適用於文本陰影。

您指定了水平陰影,垂直陰影,模糊的距離,以及陰影的顏色:

<style>h1{    text-shadow: 5px 5px 5px #FF0000;}</style>

 

 

1.  CSS3 box-shadow屬性

CSS3 中 CSS3 box-shadow 屬性適用於盒子陰影

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

 

 

 

接下來給陰影添加顏色
div {    box-shadow: 10px 10px 5px grey;}

 

 

 

2.  CSS3 Text Overflow屬性

CSS3文本溢出屬性指定應向使用者如何顯示溢出內容

 

<!DOCTYPE html><html><head><meta charset="utf-8"> <title>菜鳥教程(runoob.com)</title> <style> div.test{    white-space:nowrap;     width:12em;     overflow:hidden;     border:1px solid #000000;}</style></head><body><p>以下 div 容器內的文本無法完全顯示,可以看到它被裁剪了。</p><p>div 使用 &quot;text-overflow:ellipsis&quot;:</p><div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div><p>div 使用 &quot;text-overflow:clip&quot;:</p><div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div><p>div 使用自訂字串 &quot;text-overflow: &gt;&gt;&quot;(只在 Firefox 瀏覽器下有效):</p><div class="test" style="text-overflow:‘>>‘;">This is some long text that will not fit in the box</div></body></html>

 

 

 

 

3.  CSS3的換行

如果某個單詞太長,不適合在一個地區內,它擴充到外面:

CSS3中,自動換行屬性允許您強制文本換行 - 即使這意味著分裂它中間的一個字:

CSS代碼如下:

 

p.test{    width:11em;     border:1px solid #000000;    word-wrap:break-word;}

 

 

 

 

CSS3 單詞拆分換行

CSS3 單詞拆分換行屬性指定換行規則:

CSS代碼如下:

p.test1{    width:9em;     border:1px solid #000000;    word-break:keep-all;}p.test2{    width:9em;     border:1px solid #000000;    word-break:break-all;}</style>

 

 

總結:

 

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.