返回js改变css......登陆

js改变css属性

肖凌2019-05-11 14:02:42278

<!DOCTYPE html>

<html>

             <head>

                     <title></title>

                     <meta charset="utf-8">

                     <style type="text/css">

                     #box{

                     width:100px;height:100px;background:red;margin:20px 80px;

                     }           

                     </style>

             </head>

<body>

                 <div id="box"></div>

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

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

                 <input type="button" value="背景色" onclick="changebackground()">

                 <input type="button" value="改变形状" onclick="changecicrl()">

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

                 <input type="button" value="隐" onclick="nodisplay()">

                 <script type="text/javascript">

                 var box;

                 window.onload=function(){

                 box=document.getElementById('box');

                 }

                 function changeHeight(){

                 box.style.height="200px";

                 }

                 function changewidth(){

                 box.style.width="200px";

                 }

                 function changebackground(){

                 box.style.background='pink';

                 }

                 function changecicrl(){

                 box.style.borderRadius='50%';

                 }

                 function display(){

                 box.style.display='block';

                

                 }

                 function nodisplay(){

                 box.style.display='none';

                 }               

                 </script>




</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送