代码示例:(标识:css_background-clip2)
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf8" />
<script type="text/javascript">
<!--
function tiy_onload()
{
var PreVal=""
PreVal=document.getElementById("PreSelectedValue").value
if (PreVal!="")
{
test_demo_val(PreVal)
var x=document.getElementsByTagName("input")
var l=x.length
for (i=0;i<l;i++)
{
if (x[i].value==PreVal)
{
x[i].checked=true
}
}
}
}
function test_demo(obj)
{
test_demo_val(obj.value)
}
//-->
</script>
<script type="text/javascript">
<!--
function test_demo_val(strValue)
{
var strId="MyDIV"
document.getElementById(strId).style.backgroundClip=strValue;
document.getElementById("CodeValue").innerHTML=strValue;
}
//-->
</script>
<style>
#MyDIV
{
width:380px;
height:210px;
}
#MyDIV
{
padding:25px;
border:10px dotted #000000;
background-color:yellow;
background-clip:border-box;
}
</style>
</head>
<body>
<div id="SelArea">
<h2>CSS 属性:</h2>
<h3>background-clip:</h3>
<form action="javascript:return false;">
<ul>
<input type="hidden" id="PreSelectedValue" value="padding-box" />
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_1" value="border-box" />border-box</li>
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_2" value="padding-box" />padding-box</li>
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_3" value="content-box" />content-box</li>
</ul>
</form>
</div>
<div id="result">
<h2>结果:</h2>
<div id="DemoArea">
<div id="MyDIV">
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
</div>
</div>
<h2>CSS 代码:</h2>
<pre id="CodeArea">
#MyDIV
{
padding:25px;
border:10px dotted #000000;
background-color:yellow;
background-clip:<span id="CodeValue">border-box</span>;
}
</pre>
</div>
</body>
<script type="text/javascript">tiy_onload()</script>
</html>