Home > Web Front-end > HTML Tutorial > 2015.08.11-Background color switching function_html/css_WEB-ITnose

2015.08.11-Background color switching function_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:39:03
Original
1323 people have browsed it

Simple demo, click to switch the background color, and attach the code.


.html file

<div> class='red' id="box">美美哒!...........</div>
Copy after login

.css file

.red{   width:100px;   height:100px;   background-color:red;   border-radius:0 70px 0 60px ;   transition-duration:1s;}.yellow{ width:150px; height:150px; border-radius:80px 0 100px 0; transition-duration:1s; background-color:yellow;}
Copy after login

.js file

window.onload = function(){  var box = document.getElementById('box');  box.onclick = toYellow;};function toRed(){   this.className ='red';   this.onclick = toYellow;}function toYellow(){  this.className ='yellow';  this.onclick = toRed;}
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template