_ios7-switch.scss 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. .switch {
  2. display: inline-block;
  3. vertical-align: middle;
  4. cursor: pointer;
  5. margin: 3px 0;
  6. .ios-switch {
  7. height: 35px;
  8. width: 65px;
  9. .handle {
  10. height: 31px;
  11. width: 31px;
  12. }
  13. }
  14. @each $state in $states {
  15. &.switch-#{nth($state,1)} {
  16. .ios-switch .on-background {
  17. background: #{nth($state,2)};
  18. }
  19. }
  20. }
  21. &.switch-lg {
  22. .ios-switch {
  23. height: 45px;
  24. width: 75px;
  25. .handle {
  26. height: 41px;
  27. width: 41px;
  28. }
  29. }
  30. }
  31. &.switch-sm {
  32. .ios-switch {
  33. height: 25px;
  34. width: 55px;
  35. .handle {
  36. height: 21px;
  37. width: 21px;
  38. }
  39. }
  40. }
  41. }
  42. .ios-switch {
  43. height: 45px;
  44. width: 75px;
  45. position: relative;
  46. background-color: #E5E5E5;
  47. border-radius: 100px;
  48. -webkit-backface-visibility: hidden;
  49. -moz-backface-visibility: hidden;
  50. backface-visibility: hidden;
  51. }
  52. .ios-switch .background-fill {
  53. width: 100%;
  54. height: 100%;
  55. border-radius: 100px;
  56. position: absolute;
  57. left: 0;
  58. top: 0;
  59. }
  60. .ios-switch .on-background {
  61. background-image: -o-linear-gradient(#00e459, #00e158);
  62. background-image: -ms-linear-gradient(#00e459, #00e158);
  63. background-image: -moz-linear-gradient(#00e459, #00e158);
  64. background-image: -webkit-linear-gradient(#00e459, #00e158);
  65. background-image: linear-gradient(#00e459, #00e158);
  66. opacity: 0;
  67. -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
  68. filter: alpha(opacity=0);
  69. z-index: 1;
  70. -o-transition: .3s 0.2s;
  71. -ms-transition: .3s 0.2s;
  72. -moz-transition: .3s 0.2s;
  73. -webkit-transition: .3s 0.2s;
  74. transition: .3s 0.2s;
  75. }
  76. .ios-switch .state-background {
  77. border-radius: 100px;
  78. z-index: 2;
  79. background-image: -o-linear-gradient(#ffffff, #FDFDFD);
  80. background-image: -ms-linear-gradient(#ffffff, #FDFDFD);
  81. background-image: -moz-linear-gradient(#ffffff, #FDFDFD);
  82. background-image: -webkit-linear-gradient(#ffffff, #FDFDFD);
  83. background-image: linear-gradient(#ffffff, #FDFDFD);
  84. border: 2px solid #E5E5E5;
  85. -o-box-sizing: border-box;
  86. -ms-box-sizing: border-box;
  87. -moz-box-sizing: border-box;
  88. -webkit-box-sizing: border-box;
  89. box-sizing: border-box;
  90. -o-transform: scale(1);
  91. -ms-transform: scale(1);
  92. -moz-transform: scale(1);
  93. -webkit-transform: scale(1);
  94. transform: scale(1);
  95. -o-transition: .4s;
  96. -ms-transition: .4s;
  97. -moz-transition: .4s;
  98. -webkit-transition: .4s;
  99. transition: .4s;
  100. }
  101. .ios-switch .handle {
  102. width: 41px;
  103. height: 41px;
  104. background-color: white;
  105. top: 2px;
  106. left: 2px;
  107. position: absolute;
  108. border-radius: 20px;
  109. box-shadow: 0 0 3px 1px hsla(0, 0%, 0%, .075), 0 3px 5px hsla(0, 0%, 0%, .15), 1px 2px 2px hsla(0, 0%, 0%, .05);
  110. z-index: 3;
  111. -o-transition: -o-transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  112. -ms-transition: -ms-transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  113. -moz-transition: -moz-transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  114. -webkit-transition: -webkit-transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  115. -o-transition: transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  116. -ms-transition: transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  117. -moz-transition: transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  118. -webkit-transition: transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  119. transition: transform .3s 0.25s cubic-bezier(0.455, 0.030, 0.215, 1.330);
  120. -o-box-sizing: content-box;
  121. -ms-box-sizing: content-box;
  122. -moz-box-sizing: content-box;
  123. -webkit-box-sizing: content-box;
  124. box-sizing: content-box;
  125. }
  126. .ios-switch.off .handle {
  127. -o-animation: expand-off .3s 0.2s;
  128. -ms-animation: expand-off .3s 0.2s;
  129. -moz-animation: expand-off .3s 0.2s;
  130. -webkit-animation: expand-off .3s 0.2s;
  131. animation: expand-off .3s 0.2s;
  132. -o-transform: translate(0px, 0);
  133. -ms-transform: translate(0px, 0);
  134. -moz-transform: translate(0px, 0);
  135. -webkit-transform: translate(0px, 0);
  136. transform: translate(0px, 0);
  137. -o-transform: translate3d(0px, 0, 0);
  138. -ms-transform: translate3d(0px, 0, 0);
  139. -moz-transform: translate3d(0px, 0, 0);
  140. -webkit-transform: translate3d(0px, 0, 0);
  141. transform: translate3d(0px, 0, 0);
  142. }
  143. .ios-switch.off .on-background {
  144. -o-transition: .3s 0s;
  145. -ms-transition: .3s 0s;
  146. -moz-transition: .3s 0s;
  147. -webkit-transition: .3s 0s;
  148. transition: .3s 0s;
  149. }
  150. .ios-switch.off .state-background {
  151. -o-transition: .4s 0.25s;
  152. -ms-transition: .4s 0.25s;
  153. -moz-transition: .4s 0.25s;
  154. -webkit-transition: .4s 0.25s;
  155. transition: .4s 0.25s;
  156. }
  157. .ios-switch.on .handle {
  158. -o-animation: expand-on .3s 0.2s;
  159. -ms-animation: expand-on .3s 0.2s;
  160. -moz-animation: expand-on .3s 0.2s;
  161. -webkit-animation: expand-on .3s 0.2s;
  162. animation: expand-on .3s 0.2s;
  163. -o-transform: translate(30px, 0);
  164. -ms-transform: translate(30px, 0);
  165. -moz-transform: translate(30px, 0);
  166. -webkit-transform: translate(30px, 0);
  167. transform: translate(30px, 0);
  168. -o-transform: translate3d(30px, 0, 0);
  169. -ms-transform: translate3d(30px, 0, 0);
  170. -moz-transform: translate3d(30px, 0, 0);
  171. -webkit-transform: translate3d(30px, 0, 0);
  172. transform: translate3d(30px, 0, 0);
  173. }
  174. .ios-switch.on .on-background {
  175. opacity: 1;
  176. -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
  177. filter: alpha(opacity=100);
  178. }
  179. .ios-switch.on .state-background {
  180. -o-transform: scale(0);
  181. -ms-transform: scale(0);
  182. -moz-transform: scale(0);
  183. -webkit-transform: scale(0);
  184. transform: scale(0);
  185. }
  186. @keyframes expand-on {
  187. 0% {
  188. padding-right: 0;
  189. }
  190. 40% {
  191. padding-right: 9px;
  192. }
  193. 100% {
  194. padding-right: 0;
  195. }
  196. }
  197. @keyframes expand-off {
  198. 0% {
  199. padding-right: 0;
  200. left: 2px;
  201. }
  202. 40% {
  203. padding-right: 9px;
  204. left: -7px;
  205. }
  206. 100% {
  207. padding-right: 0;
  208. left: 2px;
  209. }
  210. }
  211. @-o-keyframes expand-on {
  212. 0% {
  213. padding-right: 0;
  214. }
  215. 40% {
  216. padding-right: 9px;
  217. }
  218. 100% {
  219. padding-right: 0;
  220. }
  221. }
  222. @-ms-keyframes expand-on {
  223. 0% {
  224. padding-right: 0;
  225. }
  226. 40% {
  227. padding-right: 9px;
  228. }
  229. 100% {
  230. padding-right: 0;
  231. }
  232. }
  233. @-moz-keyframes expand-on {
  234. 0% {
  235. padding-right: 0;
  236. }
  237. 40% {
  238. padding-right: 9px;
  239. }
  240. 100% {
  241. padding-right: 0;
  242. }
  243. }
  244. @-webkit-keyframes expand-on {
  245. 0% {
  246. padding-right: 0;
  247. }
  248. 40% {
  249. padding-right: 9px;
  250. }
  251. 100% {
  252. padding-right: 0;
  253. }
  254. }
  255. @-o-keyframes expand-off {
  256. 0% {
  257. padding-right: 0;
  258. left: 2px;
  259. }
  260. 40% {
  261. padding-right: 9px;
  262. left: -7px;
  263. }
  264. 100% {
  265. padding-right: 0;
  266. left: 2px;
  267. }
  268. }
  269. @-ms-keyframes expand-off {
  270. 0% {
  271. padding-right: 0;
  272. left: 2px;
  273. }
  274. 40% {
  275. padding-right: 9px;
  276. left: -7px;
  277. }
  278. 100% {
  279. padding-right: 0;
  280. left: 2px;
  281. }
  282. }
  283. @-moz-keyframes expand-off {
  284. 0% {
  285. padding-right: 0;
  286. left: 2px;
  287. }
  288. 40% {
  289. padding-right: 9px;
  290. left: -7px;
  291. }
  292. 100% {
  293. padding-right: 0;
  294. left: 2px;
  295. }
  296. }
  297. @-webkit-keyframes expand-off {
  298. 0% {
  299. padding-right: 0;
  300. left: 2px;
  301. }
  302. 40% {
  303. padding-right: 9px;
  304. left: -7px;
  305. }
  306. 100% {
  307. padding-right: 0;
  308. left: 2px;
  309. }
  310. }