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>
    

      

    效果图:

  • 相关阅读:
    mysql远程登录
    Linux下FTP服务器配置与管理
    linux编程的相对路径问题解决
    ERROR 1935_WIN7注册表大小的限制
    linux下jdk,tomcat的安装和配置
    使用Validator.validateAll验证Form
    mysql常用命令集合
    B or D
    Delphi开发日志系列文章的示例源码
    delphi开发日志——主窗体,程序管家
  • 原文地址:https://www.cnblogs.com/xuhang/p/4433008.html
Copyright © 2011-2022 走看看