CSS的content屬性

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS的content屬性</title>
<style type="text/css">
    html,body{width:100%; height:100%;}
    *{margin:0; padding:0;}
    #wrap{width:60%; maring:100px auto 0; background:#996;}
    h1:before{content:"用於before";color:#FFC;}
    h1:after{content:"用於after";color:#900;}
    h2:before,h2:after{content:"";}
</style>
</head>
<body>
    <div id="wrap">
        <h1>CSS的content屬性用於定義字符串</h1>
        <h2>CSS的content屬性適用於:before與:after僞類。</h2>
    </div>
</body>
</html>



CSS的content屬性用於定義字符串,適用於:before與:after僞類。

支持firefox,chrome,safari,opera,IE8。

下圖是以上代碼的效果:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章