<!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">



<div class="oc">
<i></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...