The document contains examples of using JavaScript to modify various CSS style properties of HTML elements, including background, border, font, overflow, padding, and transition properties. Code snippets show how to select elements by ID and change properties like background color, image, position, border width and style, font family and size, overflow behavior, padding, and transition timing function on hover.
10. <body>
<p>Click the "Try it" button to setthe boxShadow property of the DIV element:</p>
<button onclick="myFunction()">Tryit</button>
<div id="myDIV">
<h1>myDIV</h1>
</div>
<script>
functionmyFunction() {
document.getElementById("myDIV").style.boxShadow="10px 20px 30px lightblue";
}
</script>
</body>
</html>
<!DOCTYPE html>display
<html>
<head>
<style>
#myDIV {
width: 500px;
height:500px;
background-color: lightblue;
}
</style>
</head>
<body>
<p>Click the "Try it" button to setthe displayproperty of the DIV elementto"none":</p>
<button onclick="myFunction()">Tryit</button>
<div id="myDIV">
This is my DIV element.
</div>
<p><b>Note:</b> The elementwill nottake up any space whenthe displayproperty set to
"none".</p>
<script>
functionmyFunction() {
document.getElementById("myDIV").style.display="none";
}
</script>
</body>
</html>
12. document.getElementById("myDiv").style.lineHeight="3";
document.getElementById("myList").style.listStyle ="decimal inside";
document.getElementById("myList").style.listStyleImage="url('sqorange.gif')";
document.getElementById("myDiv").style.margin="50px 10px 20px 30px";
document.getElementById("myDiv").style.marginBottom="50px";
<!DOCTYPE html>overflow
<html>
<head>
<style>
#myDIV {
border: 1px solid black;
background-color: lightblue;
width: 300px;
height:210px;
overflow:visible;
}
</style>
</head>
<body>
<p>Click the "Try it" button to change the overflowproperty ofthe DIV element:</p>
<button onclick="myFunction()">Tryit</button>
<div id="myDIV">
Lorem ipsumdolor sit amet, consectetueradipiscingelit,seddiam nonummynibh euismodtincidunt
ut laoreetdolore magna aliquam erat volutpat. Ut wisi enimad minimveniam,quis nostrud exerci
type extra
</div>
<script>
functionmyFunction() {
document.getElementById("myDIV").style.overflow="scroll";
}
</script>
</body>
</html>
document.getElementById("myDIV").style.overflowX="scroll";
document.getElementById("myDIV").style.overflowX="scroll";
document.getElementById("myDiv").style.padding="50px 10px 20px 30px";
<!DOCTYPE html> Transform
<html>
<head>
<style>
#myDIV {
margin: auto;
border: 1px solid black;
13. width: 200px;
height:100px;
background-color: coral;
color: white;
}
</style>
</head>
<body>
<p>Click the "Try it" button to rotate the DIV element:</p>
<button onclick="myFunction()">Tryit</button>
<div id="myDIV">
<h1>myDIV</h1>
</div>
<script>
functionmyFunction() {
// Code for Chrome, Safari, Opera
document.getElementById("myDIV").style.WebkitTransform="rotate(20deg)";
// Code for IE9
document.getElementById("myDIV").style.msTransform="rotate(20deg)";
// Standard syntax
document.getElementById("myDIV").style.transform="rotate(20deg)";
}
</script>
</body>
</html>
<!DOCTYPE html>transitionTimingFunction
<html>
<head>
<style>
#myDIV {
border: 1px solid black;
background-color: lightblue;
width: 270px;
height:200px;
overflow:auto;
-webkit-transition:all 2s; /* For Safari 3.1 to 6.0 */
transition: all 2s;
}
#myDIV:hover {
background-color: coral;
width: 570px;
height:500px;
padding: 100px;
14. border-radius:50px;
}
</style>
</head>
<body>
<p>Mouse overthe DIV elementand it will change,gradually, both in color and size!</p>
<p>Click the "Try it" button and mouse over the DIV elementagain. The changes will now happen ina
linearspeedcurve.</p>
<button onclick="myFunction()">Tryit</button>
<div id="myDIV">
<h1>myDIV</h1>
</div>
<script>
functionmyFunction() {
document.getElementById("myDIV").style.WebkitTransitionTimingFunction="linear";// Code for
Safari 3.1 to 6.0
document.getElementById("myDIV").style.transitionTimingFunction ="linear"; // Standard
syntax
}
</script>
<p><strong>Note:</strong> The transitionTimingFunctionpropertyis supportedin InternetExplorer
10, Firefox,Opera,and Chrome.</p>
<p>Safari supports an alternative,the WebkitTransitionTimingFunctionproperty.</p>
</body>
</html>