zoukankan      html  css  js  c++  java
  • css布局之选择切换按钮

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    	<title>Document</title>
    </head>
    <style>
    	.btn-change{
    		 120px;
    		height: 40px;
    		border-radius: 20px;
    		border: 1px solid #dedede;
    		font-size: 1.3em;
    		margin: 0 auto;
    		position: relative;
    		overflow: hidden;
    	}
    	.btn-dot{
    		height: 40px;
    		 40px;
    		background-color: #dedede;
    		border-radius: 20px;
    		position: absolute;
    		z-index: 99;
    	}
    
    	.btn-left{
    		background-color:#74B700; 
    		position: absolute;
    		 100px;
    		height: 40px;
    		line-height: 40px;
    		left: -80px;
    		color: #fff;
    		text-align: left;
    		padding-left: 40px;
    	}
    	
    	.btn-move{
    		position: absolute;
    		left:0;
    		-webkit-transition: all .3s;-moz-transition: all .3s;transition: all .3s;
    	}
    
    	.switch.btn-move{
    		left:80px;
    	}
    	.btn-right{
    		background-color: #ebebeb;
    		position: absolute;
    		 100px;
    		height: 40px;
    		line-height: 40px;
    		text-align: left;
    		padding-left: 20px;
    		left: 20px;
    		color: #333;
    	}
    	
    </style>
    <body>
    <div class="btn-change">
    	<div class="btn-move">
            <div class="btn-left">关注</div>
            <div class="btn-dot"></div>
            <div class="btn-right">未关注</div>
        </div>
    </div>
    </body>
    </html>
    <script src="jquery-1.10.2.js"></script>
    <script>
    	$(function(){
    		$(".btn-move").click(function(){
    			$(this).toggleClass("switch");
    		})
    	})
    </script>
    

      

    效果图:

  • 相关阅读:
    细菌觅食优化算法
    windows文件名编码格式测试结果及猜想
    Exception
    maven创建web项目注意事项
    Majaro安装卡在Fixing hardcoded icons原因
    gnome更改ibus输入法候选词字体大小
    MariaDB用zip包安装
    JAVA获取时间戳
    自增不连续解决方案
    WEB项目目录结构
  • 原文地址:https://www.cnblogs.com/xuhang/p/4433008.html
Copyright © 2011-2022 走看看