checkbox.less 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. //some checkbox & switch variables
  2. @checkbox-color: #32A3CE;
  3. @checkbox-border-color: #C8C8C8;
  4. @checkbox-checked-border: #ADB8C0;
  5. @checkbox-hover-border: #FF893C;
  6. @checkbox2-bg: #F9A021;
  7. @switch-checked-bg: #8AB2C9;
  8. @switch-checked-border: #6A8CA8;
  9. @switch4-bg: #8B9AA3;
  10. @switch4-color: #939393;
  11. @switch4-checked-bg: #468FCC;
  12. @switch6-checked-border: #B7D3E5;
  13. @switch6-checked-bg: #FF893C;
  14. @switch7-checked-bg: #468FCC;
  15. @switch7-checked-border: #6FB3E0;
  16. @switch-1-text: "ON\a0\a0\a0\a0\a0\a0\a0\a0\a0OFF";
  17. @switch-2-text: "YES\a0\a0\a0\a0\a0\a0\a0\a0\a0NO";
  18. @switch-4-text: "ON\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0OFF";
  19. @switch-5-text: "YES\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0NO";
  20. @switch-7-text: "OFF\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0ON";
  21. @lbl_selector: ~"+ .lbl";
  22. //@lbl_selector: ~"~ .lbl";//uncomment for ASP.NET or use css builder tool
  23. .enable_checkbox() when(@enable-checkbox = true) {
  24. //Checkbox & Radio
  25. @lbl: @lbl_selector;//+ .lbl or ~ .lbl (for ASP.NET)
  26. input[type=checkbox].ace , input[type=radio].ace {
  27. opacity: 0;
  28. position: absolute;
  29. z-index: 1;//so that it is clickable and above (.lbl)
  30. width: 18px;
  31. height: 18px;
  32. cursor: pointer;
  33. label & {
  34. z-index: -100 !important;
  35. width: 1px !important;//width '0' has issues with jQuery Validate not recognizing this
  36. height: 1px !important;
  37. clip: rect(1px, 1px, 1px, 1px);
  38. position: absolute;//"fixed" causes issues on iOS safari?!
  39. //we don't need it to be hoverable/clickable when inside a label
  40. }
  41. &:checked, &:focus {
  42. outline: none !important;
  43. }
  44. @{lbl} {
  45. position: relative;
  46. display:inline-block;
  47. margin:0;
  48. line-height:20px;
  49. min-height:18px;
  50. min-width:18px;
  51. font-weight:normal;
  52. cursor: pointer;
  53. &::before {
  54. cursor: pointer;
  55. font-family: fontAwesome;
  56. font-weight: normal;
  57. font-size: 12px;
  58. color: @checkbox-color;
  59. content: "\a0";
  60. display: inline-block;
  61. background-color: #FAFAFA;
  62. border: 1px solid @checkbox-border-color;
  63. box-shadow: 0 1px 2px rgba(0,0,0,0.05);/*, inset 0px -15px 10px -12px rgba(0,0,0,0.05);*/
  64. border-radius: 0;
  65. display: inline-block;
  66. text-align: center;
  67. //vertical-align: text-bottom;
  68. //vertical-align: middle;
  69. height: 16px;
  70. line-height: 14px;
  71. min-width: 16px;
  72. margin-right: 1px;
  73. position: relative;
  74. top: -1px;
  75. }
  76. }//.lbl
  77. &:checked @{lbl}::before ,
  78. {
  79. display:inline-block;
  80. content: '\f00c';
  81. background-color: #F5F8FC;
  82. border-color:@checkbox-checked-border;
  83. box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1);
  84. }
  85. &:hover @{lbl}::before , @{lbl}:hover::before {
  86. border-color:@checkbox-hover-border;
  87. }
  88. &:active , &:checked:active {
  89. @{lbl}::before {
  90. box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1);
  91. }
  92. }
  93. &.ace-checkbox-2 @{lbl}::before {
  94. box-shadow: none;
  95. }
  96. &.ace-checkbox-2:checked @{lbl}::before {
  97. background-color: @checkbox2-bg;
  98. border-color: @checkbox2-bg;
  99. color: #FFF;
  100. }
  101. &:disabled @{lbl}::before ,
  102. &[disabled] @{lbl}::before ,
  103. &.disabled @{lbl}::before {
  104. background-color:#DDD !important;
  105. border-color:#CCC !important;
  106. box-shadow:none !important;
  107. color:#BBB;
  108. }
  109. }
  110. //opera fix
  111. //no_such_element:-o-prefocus, input[type=checkbox].ace @{lbl}::before, input[type=radio].ace @{lbl}::before {
  112. //vertical-align: middle;
  113. //}
  114. .checkbox label input[type=checkbox].ace @{lbl}, .radio label input[type=radio].ace @{lbl} {
  115. margin-left: -10px;
  116. }
  117. input.ace @{lbl} {
  118. .checkbox-paddings() {// a little paddings for .lbl
  119. .checkbox-paddingX (@index) when (@index >= 0) {
  120. &.padding-@{index}::before {
  121. margin-right: unit(@index,px);
  122. }
  123. .checkbox-paddingX(@index - 2);
  124. }
  125. .checkbox-paddingX(16);
  126. }
  127. .checkbox-paddings();
  128. }
  129. /**
  130. input[type=radio].ace @{lbl}::before {
  131. border-radius:100%;
  132. font-size: 34px;
  133. font-family: Helvetica, Arial, "Sans-Serif";//looks better but incosistent
  134. line-height: 13px;
  135. }
  136. */
  137. input[type=radio].ace @{lbl}::before {
  138. border-radius: 100%;
  139. font-size: 10px;
  140. font-family: FontAwesome;//let's use a fonts that's available everywhere
  141. text-shadow: 0 0 1px @checkbox-color;
  142. line-height: 15px;
  143. height: 17px;
  144. min-width: 17px;
  145. }
  146. input[type=radio].ace:checked @{lbl}::before {
  147. content:"\f111";
  148. }
  149. /* CSS3 on/off switches */
  150. //use like <input type="checkbox" class="ace ace-switch" /> <span class="lbl"></span>
  151. .enable_switches() when(@enable-switch = true) {
  152. input[type=checkbox].ace.ace-switch {
  153. width: 55px;
  154. height: 25px;
  155. @{lbl} {
  156. margin:0 4px;
  157. min-height:24px;
  158. &::before {
  159. font-family: 'Open Sans';
  160. content: @switch-1-text;
  161. color: #999;
  162. text-shadow: 0 0 0 #999;
  163. font-weight: normal;
  164. font-size: 11px;
  165. line-height: 17px;// line-height:21px \9;/*ie9*/
  166. height: 20px;
  167. overflow: hidden;
  168. border-radius: 12px;
  169. background-color: #F5F5F5;
  170. //.box-shadow(~"inset 0px 2px 2px 0px rgba(0,0,0,.2)");
  171. .box-shadow(~"inset 0 1px 1px 0 rgba(0, 0, 0, 0.15)");
  172. border: 1px solid #CCC;
  173. text-align: left;
  174. float: left;
  175. padding: 0;
  176. width: 52px;
  177. text-indent: -21px;// text-indent: -21px \9;
  178. margin-right: 0;
  179. .transition(~"text-indent .3s ease");
  180. top: auto;
  181. }
  182. &::after {
  183. font-family: 'Open Sans';
  184. content: 'III';
  185. font-size: 12px;
  186. font-weight: normal;
  187. letter-spacing: 0;
  188. color: #AAA;
  189. text-shadow: none;
  190. //text-shadow: 0 0 0 #999;
  191. background-color: #FFF;
  192. //text-align: center;
  193. //text-indent: -2px;
  194. border-radius: 100%;
  195. width: 22px;
  196. height: 22px;
  197. line-height: 22px;
  198. text-align: center;
  199. position: absolute;
  200. top: -2px;
  201. left: -3px;
  202. .box-shadow(~"0px 1px 1px 1px rgba(0,0,0,.3)");
  203. //text-shadow:0px 1px 1px rgba(0,0,0,0.3) inset;
  204. .transition(~"left .3s ease");
  205. }
  206. }
  207. &:checked @{lbl} {
  208. &::before {
  209. text-indent: 8px;
  210. color: #FFF;
  211. text-shadow: 0 0 0 #FFF;
  212. background-color: @switch-checked-bg;
  213. border-color: @switch-checked-border;
  214. }
  215. &::after {
  216. left: 34px;
  217. background-color: #FFF;
  218. color: #98A0A5;
  219. //text-shadow: 0 0 0 #465868;
  220. }
  221. }
  222. &.ace-switch-2 @{lbl}::before {
  223. content: @switch-2-text;
  224. }
  225. &.ace-switch-3 @{lbl}::after {
  226. font-family: FontAwesome;
  227. font-size: 13px;
  228. line-height: 22px;
  229. content: "\f00d";
  230. top: -1px;
  231. text-shadow: none;
  232. padding: 0;
  233. text-align: center;
  234. color: #BBB;
  235. letter-spacing: 0;
  236. }
  237. &.ace-switch-3:checked @{lbl}::after {
  238. content: "\f00c";
  239. color: #8AB2C9;
  240. text-shadow: none;
  241. }
  242. //switch style 4 & 5
  243. .enable_switch_style_4() when(@enable-switch-style-4 = true) {
  244. &.ace-switch-4 , &.ace-switch-5 {
  245. width: 60px;
  246. @{lbl}::before {
  247. content: @switch-4-text;
  248. //font-family:Arial, Helvetica, sans-serif;
  249. //font-weight:bolder;
  250. font-size: 12px;
  251. line-height: 21px;
  252. height: 24px;
  253. overflow: hidden;
  254. //line-height:25px \9;
  255. border-radius: 12px;
  256. display: inline-block;
  257. background-color: @switch4-bg;
  258. border: 1px solid @switch4-bg;
  259. color: #FFF;
  260. width: 56px;
  261. text-indent: -25px;// text-indent: -28px \9;
  262. text-shadow: 0 0 0 #FFF;
  263. display: inline-block;
  264. position: relative;
  265. //margin-right:8px;
  266. box-shadow:none;
  267. .transition(~"all .3s ease");
  268. }
  269. @{lbl}::after {
  270. content: 'III';
  271. font-size: 11px;
  272. position: absolute;
  273. top: 2px;
  274. left: 2px;
  275. letter-spacing: 0;
  276. width: 20px;
  277. height: 20px;
  278. line-height: 19px;
  279. text-shadow: none !important;
  280. color: @switch4-color;
  281. background-color:#FFF;
  282. .transition(~"all .3s ease");
  283. }
  284. &:checked @{lbl} {
  285. &::before {
  286. text-indent: 9px;
  287. background-color: @switch4-checked-bg;
  288. border-color: #468FCC;
  289. }
  290. &::after {
  291. left: 34px;
  292. background-color: #FFF;
  293. color: darken(@switch4-color , 6%);
  294. }
  295. }
  296. }
  297. &.ace-switch-5 @{lbl}::before {
  298. content: @switch-5-text;
  299. }
  300. &.ace-switch-5:checked @{lbl}::before {
  301. text-indent: 8px;
  302. }
  303. }
  304. .enable_switch_style_4();
  305. .enable_switch_style_6() when(@enable-switch-style-6 = true) {
  306. //switch style 6
  307. &.ace-switch-6 {
  308. @{lbl} {
  309. position: relative;
  310. &::before {
  311. font-family: FontAwesome;
  312. content: "\f00d";
  313. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  314. box-shadow: none;
  315. border-width: 0;
  316. font-weight: lighter;
  317. font-size: 16px;
  318. border-radius: 12px;
  319. display: inline-block;
  320. background-color: #888;
  321. color: #F2F2F2;
  322. width: 52px;
  323. height: 22px;
  324. line-height: 21px;
  325. text-indent: 32px;
  326. .transition(~"background 0.1s ease");
  327. }
  328. &::after {
  329. content: ''; text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);
  330. position: absolute;
  331. top: 2px;
  332. left: 3px;
  333. border-radius: 12px;
  334. box-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);
  335. width: 18px;
  336. height: 18px;
  337. text-align: center;
  338. background-color: #F2F2F2;
  339. border: 4px solid #F2F2F2;
  340. .transition(~"left 0.2s ease");
  341. }
  342. }
  343. &:checked @{lbl} {
  344. &::before {
  345. content: "\f00c";
  346. text-indent:6px;
  347. color:#FFF;
  348. border-color:@switch6-checked-border;
  349. background-color:@switch6-checked-bg;
  350. }
  351. &::after {
  352. left:32px;
  353. background-color:#FFF;
  354. border:4px solid #FFF;
  355. text-shadow:0 -1px 0 rgba(0, 200, 0, 0.25);
  356. }
  357. }
  358. }
  359. }
  360. .enable_switch_style_6();
  361. .enable_switch_style_7() when(@enable-switch-style-7 = true) {
  362. &.ace-switch-7 {
  363. width:75px;
  364. @{lbl} {
  365. position: relative;
  366. &::before {
  367. content: @switch-7-text;
  368. font-weight: bolder;
  369. font-size: 13px;
  370. line-height: 20px;
  371. display: inline-block;
  372. background-color: #FFF;
  373. border: 2px solid #AAA;
  374. border-radius: 0;
  375. box-shadow: none;
  376. color: #AAA;
  377. width: 74px;
  378. height: 26px;
  379. line-height: 22px;
  380. overflow: hidden;
  381. text-indent: 5px;
  382. display: inline-block;
  383. position: relative;
  384. //margin-right:8px;
  385. .transition(~"all 0.2s ease");
  386. }
  387. &::after {
  388. content: '\f00d';
  389. font-family: FontAwesome;
  390. font-size: 16px;
  391. position: absolute;
  392. top: 3px;
  393. left: 39px;
  394. width: 32px;
  395. height: 20px;
  396. line-height: 18px;
  397. text-align: center;
  398. padding: 0;
  399. text-indent: 0;
  400. background-color: #AAA;
  401. color: #FFF;
  402. border-radius: 0;
  403. box-shadow: none;
  404. .transition(~"all 0.2s ease-in-out");
  405. }
  406. }
  407. &:checked @{lbl} {
  408. &::before {
  409. color: @switch7-checked-bg;
  410. background-color: #FFF;
  411. text-indent: -28px;
  412. border-color: @switch7-checked-border;
  413. }
  414. &::after {
  415. left: 3px;
  416. content: '\f00c';
  417. background-color: @switch7-checked-bg;
  418. color: #FFF;
  419. }
  420. }
  421. }
  422. }
  423. .enable_switch_style_7();
  424. }
  425. //any custom text
  426. input[type=checkbox].ace.ace-switch @{lbl}[data-lbl]::before {
  427. content: attr(data-lbl);
  428. }
  429. input[type=checkbox].ace.ace-switch.btn-empty @{lbl}::after {
  430. content: "";
  431. }
  432. input[type=checkbox].ace.ace-switch.btn-rotate @{lbl}::after {
  433. content: "\2261";// the 3 line (menu) character
  434. line-height: 20px;
  435. font-size:17px;
  436. }
  437. input[type=checkbox].ace.ace-switch-4.btn-rotate @{lbl}::after,
  438. input[type=checkbox].ace.ace-switch-5.btn-rotate @{lbl}::after {
  439. line-height: 17px;
  440. }
  441. //flat, square
  442. input[type=checkbox].ace.ace-switch.btn-flat @{lbl}::before,
  443. input[type=checkbox].ace.ace-switch.btn-flat @{lbl}::after {
  444. border-radius: 0 !important;
  445. }
  446. input[type=checkbox].ace.ace-switch.ace-switch-4 , input[type=checkbox].ace.ace-switch.ace-switch-5 {
  447. @{lbl}::before {
  448. text-indent: -24px;
  449. }
  450. &:checked @{lbl}::before {
  451. text-indent: 7px;
  452. }
  453. }
  454. }
  455. .enable_switches();
  456. }
  457. .enable_checkbox();