设置css样式

Original 2019-03-30 17:34:11 268
abstract:总结css样改变时格式:style.width。。。。等<!DOCTYPE html><html><head> <title></title> <style type="text/css"> .box{ width: 100px; height: 100px; background: pink

总结

css样改变时格式:style.width。。。。等

<!DOCTYPE html>

<html>

<head>

<title></title>

<style type="text/css">

.box{

width: 100px;

height: 100px;

background: pink;

margin: 50px 80px;

}

</style>

</head>

<body>

  <div class ="box">

 

  </div>


  <input type="button" name="" value="变高" onclick="hei()">

  <input type="button" name="" value="变宽" onclick="wid()">

  <input type="button" name="" value="变色" onclick="bac()">

  <input type="button" name="" value="重置" onclick="rec()">

  <input type="button" name="" value="隐藏" onclick="hid()">

  <input type="button" name="" value="显示" onclick="hids()">

  <script type="text/javascript">

  var box

  window.onload=function(){

  box=document.getElementsByClassName('box')[0];

  }

     function hei(){

      box.style.height="400px";

     }

     function wid(){

      box.style.width="400px";

     }

     function bac(){

      box.style.background="green";

     }

     function rec(){

      box.style.height="100px";

      box.style.width="100px";

      box.style.background="pink";

      box.style.borderRadius="0px";


     }

     function hid(){

      box.style.display="none";

     }

     function hids(){

      box.style.height="400px";

      box.style.width="400px";

      box.style.background="pink";

      box.style.display="block";

      box.style.borderRadius="200px";

     }

  </script>

</body>

</html>

1553938300441411.jpg

Correcting teacher:天蓬老师Correction time:2019-04-01 09:42:00
Teacher's summary:你的函数命名, 好清新呀 , 居然没看出意义来, 下次用一些有意义的名称, 通常函数是一系列的运作, 建议使用动宾结构, 例如: setColor(), getName()之类的

Release Notes

Popular Entries