<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Inline Rule Scripting</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<div id="test"> CSS Rules in Action </div>
<hr />
<script type="text/javascript">
<!--
theElement = document.getElementById("test");
//-->
</script>
<form id="cssForm" name="cssForm" action="#" method="get">
<strong>Alignment:</strong>
<select
οnchange="theElement.style.textAlign=this.options[this.selectedIndex].text;">
<option>left</option>
<option>center</option>
<option>right</option>
<option>justify</option>
</select>
<br /><br />
<strong>Font:</strong>
<select
οnchange="theElement.style.fontFamily=this.options[this.selectedIndex].text;">
<option>sans-serif</option>
<option selected="selected">serif</option>
<option>cursive</option>
<option>fantasy</option>
<option>monospace</option>
</select>
<input type="text" id="font" name="font" size="10" value="Impact" />
<input type="button" value="set" οnclick="theElement.style.fontFamily =
document.cssForm.font.value;" />
<br /><br />
<strong>Style:</strong>
<select
οnchange="theElement.style.fontStyle=this.options[this.selectedIndex].text;">
<option>normal</option>
<option>italic</option>
<option>oblique</option>
</select>
<strong>Weight:</strong>
<select οnchange="theElement.style.fontWeight=this.options[this.selectedIndex].text;">
<option>normal</option>
<option>bolder</option>
<option>lighter</option>
</select>
<strong>Variant:</strong>
<select
οnchange="theElement.style.fontVariant=this.options[this.selectedIndex].text;">
<option>normal</option>
<option>small-caps</option>
</select>
<br /><br />
<strong>Text Decoration</strong>
<select
οnchange="theElement.style.textDecoration=this.options[this.selectedIndex].text;">
<option>none</option>
<option>overline</option>
<option>underline</option>
<option>line-through</option>
<option>blink</option>
</select>
<br /><br />
<strong>Font Size:</strong>
<select
οnchange="theElement.style.fontSize=this.options[this.selectedIndex].text;">
<option>xx-small</option>
<option>x-small</option>
<option selected="selected">small</option>
<option>medium</option>
<option>large</option>
<option>x-large</option>
<option>xx-large</option>
</select>
<input type="text" id="size" name="size" size="3" maxlength="3" value="36pt" />
<input type="button" value="set" οnclick="theElement.style.fontSize =
document.cssForm.size.value;" />
<br /><br />
<strong>Color:</strong>
<input type="text" id="fgColor" name="fgColor" size="8" value="yellow" />
<input type="button" value="set" οnclick="theElement.style.color =
document.cssForm.fgColor.value;" />
<br /><br />
<strong>Background Color:</strong>
<input type="text" id="bgColor" name="bgColor" size="8" value="red" />
<input type="button" value="set" οnclick="theElement.style.backgroundColor =
document.cssForm.bgColor.value;" />
<br /><br />
<strong>Borders:</strong>
<select
οnchange="theElement.style.borderStyle=this.options[this.selectedIndex].text;">
<option>none</option>
<option>dotted</option>
<option>dashed</option>
<option>solid</option>
<option>double</option>
<option>groove</option>
<option>ridge</option>
<option>inset</option>
<option>outset</option>
</select>
<br /><br />
<strong>Height:</strong>
<input type="text" id="height" name="height" value="100px" size="3" />
<strong>Width:</strong>
<input type="text" id="width" name="width" value="100px" size="3" />
<input type="button" value="set" οnclick="theElement.style.height =
document.cssForm.height.value; theElement.style.width =
document.cssForm.width.value;" />
<br /><br />
<strong>Top:</strong>
<input type="text" id="top" name="top" value="100px" size="3" />
<strong>Left:</strong>
<input type="text" id="left" name="left" value="100px" size="3" />
<input type="button" value="Set"
οnclick="theElement.style.position='absolute';theElement.style.top =
document.cssForm.top.value; theElement.style.left = document.cssForm.left.value;"
/>
<br /><br />
<strong>Visibility</strong>
<input type="button" value="show" οnclick="theElement.style.visibility='visible';"
/>
<input type="button" value="hide" οnclick="theElement.style.visibility='hidden';"
/>
</form>
<hr />
</body>
</html>
dom和css
最新推荐文章于 2024-09-01 10:56:23 发布