js点击按钮划出菜单容器第一版



<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>js重温</title>

    <style type="text/css">
        
        .father {
            height:100px;
            width:100px;
            background-color:green;
 
            position:relative;
        }
 
        #son {
            height:50px;
            /* 隐去宽度 */
            width:10px;
            background-color:grey;
 
            position:absolute;
            top:0;
            right:100px;
 
            /* 收回的时候快一点 */
            transition:width 200ms;
        }
       
        /* 交集选择器,所以父子关系的div盒子才可以 */
         #son2 {
            /* 将transition写在;hover中,很是巧妙 */
            /* 伸展的时候慢一点 */
            width:100px;
            transition:width 800ms;           
        }
    </style>



    </head>
    <body>
    <div id="son" ></div>
        <div id="www">1111</div>
        <button type="button" onclick="replace3()">点击3</button><!--点击改变元素样式-->
    </body>
    <script>
        
         function replace3(){
            var www=document.getElementById("www");//查找元素
            www.style.color="red";//改变样式
            var www2=document.getElementById("son");//查找元素
            www2.style.width="100px";//改变样式
            www2.style.transition = "width 200ms";
           
         }
    </script>
</html>



特效为点击按钮更换颜色和 点击按钮div动态10~100 变化

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值