html中延缓背景变色速度,作业背景变色.html

Document

body,

html {

margin: 0;

}

body {

height: 100%;

}

var nav = document.createElement('nav')

document.body.appendChild(nav)

// 默认背景红色

document.body.style.backgroundColor = 'red'

nav.style.width = '100%'

nav.style.height = '40px'

nav.style.backgroundColor = 'black'

nav.style.position = 'relative'

var button1 = document.createElement('input')

document.body.appendChild(button1);

button1.style.backgroundColor = 'red'

button1.style.width = '20px'

button1.style.height = '20px'

button1.style.position = 'absolute'

button1.style.top = '10px'

button1.style.left = '3px'

button1.type = 'button'

// button1.style.border = 'none'

button1.onclick = function (event) {

event.preventDefault()

document.body.style.backgroundColor = 'red'

}

var button2 = document.createElement('input')

document.body.appendChild(button2);

button2.style.backgroundColor = 'blue'

button2.style.width = '20px'

button2.style.height = '20px'

button2.style.position = 'absolute'

button2.style.top = '10px'

button2.style.left = '30px'

button2.type = 'button'

// button2.style.border = 'none'

button2.onclick = function (event) {

event.preventDefault()

document.body.style.backgroundColor = 'blue'

}

var button3 = document.createElement('input')

document.body.appendChild(button3);

button3.style.backgroundColor = 'green'

button3.style.width = '20px'

button3.style.height = '20px'

button3.style.position = 'absolute'

button3.style.top = '10px'

button3.style.left = '58px'

button3.type = 'button'

// button3.style.border = 'none'

button3.onclick = function (event) {

event.preventDefault()

document.body.style.backgroundColor = 'green'

}

var button4 = document.createElement('input')

document.body.appendChild(button4);

button4.style.backgroundColor = 'yellow'

button4.style.width = '20px'

button4.style.height = '20px'

button4.style.position = 'absolute'

button4.style.top = '10px'

button4.style.left = '87px'

button4.type = 'button'

// button4.style.border = 'none'

button4.onclick = function (event) {

event.preventDefault()

document.body.style.backgroundColor = 'yellow'

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值