<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>开关</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
outline: 0;
}
.hb {
height: 100%;
position: relative;
max-width: 640px;
margin: 0 auto;
}
.img {
width: 88.75%;
margin: 15.31% auto 0;
position: relative;
}
.oc {
width: 12%;
position: absolute;
top: 3.25%;
right: 10%;
overflow: hidden;
background-color: #e4e4e4;
border-radius: 36px;
padding: .4% .3% .1%;
}
.oct {
transition: all .2s ease-out;
-webkit-transition: all .2s ease-out;
-moz-transition: all .2s ease-out;
-o-transition: all .2s ease-out;
}
.oc i {
display: inline-block;
width: 40%;
border-radius: 100%;
position: relative;
left: 0;
}
.oco {
background-color: #d40017 !important;
}
.oco i {
left: 60%
}
.img img{
width: 100%
}
</style>
<script type="text/javascript" src="http://t.moonbasa.com/Scripts/jquery-1.7.1.min.js?id=20141128"></script>
</head>
<body>
<div class="hb">
<div class="img" style="font-size:0">
![](http://upload-images.jianshu.io/upload_images/6449520-54a61e1423ee5f12.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/6449520-f3f054001f4cd680.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/6449520-68a49bd302b55ea0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
<div class="oc">
<i>![](http://upload-images.jianshu.io/upload_images/6449520-aee2feb8ed5f02f8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</i>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
var isSub = true;
console.log(isSub);
$(".oc").on('click', function() {
if (isSub) {
isSub = false;
$(".oc").addClass('oco').addClass("oct");
$(".oc").find("i").addClass("oct");
} else {
isSub = true;
$('.oc').removeClass('oco').addClass('oct');
$('.oc').find('i').addClass('oct');
}
});
});
</script>
</body>
</html>
开关效果
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 知识点: 1.css3 transition的使用2.label 和 checkbox的绑定3.absolute与...
- 首先,我所制作的开关效果是要放置于用 AppCan 制作的 App 中 效果图 Html代码: CSS代码: 最后...
- By Jeff Benjamin, Jan 18, 2014原链接来自 iDownloadBlog.com,htt...