js judges the odd and even numbers to realize the hidden display function and the css stereo button

 

Hello! It's been a long time, I haven't prepared any technology today, I want to meet you all if I want to. A js judges odd and even numbers to implement CSS styles. I feel that the biggest use is page navigation. Just such a small technique.

 

happy labor

 

Right! Right! Right! Right!

 

This is the three-dimensional button realized by judging the odd and even numbers, and the color matching can be changed by itself. The following is the code I throw to you:

 

css:code

<style type="text/css">
            body{
                width: 400px;
                height: 300px;
                margin: 0 auto;
                margin-top: 60px;
            }
            #div{
                width: 130px;
                height: 0px;
                border-radius:0px 0px 5px 5px;
                background-color: #808080;
                box-shadow: 0 9px 0 #808080, 0 3px 25px rgba(0, 0, 0, 0.7);
                transition: all .3s;
                margin-top: 3px;
                color: #FFFFFF;
                font-size: 20px;
                font-weight: bold;
                
                overflow: hidden;
                text-align: center;
                
            }
            #div p{
                text-shadow: 0px 0px 0px #272822;
                transition: all 2.5s;
            }
            .button{
                 width: 130px;
                height: 35px;
                border-radius: 4px;
                    box-shadow: 0 9px 0 #DB1F05, 0 9px 25px rgba(0, 0, 0, 0.7);
                background-color: #DB5705;
                transition: all 0.1s; 
                text-align: center;
                line-height: 35px;
                font-size: 14px;
                color: #FFFFFF;
                 user-select:none;
                cursor: pointer;
                font-weight: 600;
                
                     
            }
            
        </style>

HTML code:

<div class="button" onclick="dianji()">点我点我</div>
<div id="div"><p></p><p></p><p></p><p></p></div>

jquery代码:

<script type="text/javascript">
    var x=0;    
    function dianji(){        
        x++;
        //判断奇偶数利用jquery实现效果 
        
        if(x%2==0){
            $("#div").css({
                "height": "0px",
            })
            $(".button").css({
            "box-shadow": "0 9px 0 #DB1F05, 0 9px 25px rgba(0, 0, 0, 0.7)",
            })
            $("p").css({
            "text-shadow": "0px 0px 0px #272822"
            })
                
        }else{
        $("#div").css({
                "height": "200px",
                
            })
        $(".button").css({
                "box-shadow":" 0 3px 0 #DB1F05, 0 3px 6px rgba(0, 0, 0, 0.9)",
            })
        $("p").css({
            "text-shadow": "5px 5px 5px #272822"
          })
        }
    }
  </script>      

 


 

最后

 
 
                                                                                        祝大家度过一个愉快的五一假期,拜~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325028596&siteId=291194637