checkbox.less 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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: @font-size-checkbox;
  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. /**
  118. input[type=radio].ace @{lbl}::before {
  119. border-radius:100%;
  120. font-size: 34px;
  121. font-family: Helvetica, Arial, "Sans-Serif";//looks better but incosistent
  122. line-height: 13px;
  123. }
  124. */
  125. input[type=radio].ace @{lbl}::before {
  126. border-radius: 100%;
  127. font-size: @font-size-radio;
  128. font-family: FontAwesome;//let's use a fonts that's available everywhere
  129. text-shadow: 0 0 1px @checkbox-color;
  130. line-height: 15px;
  131. height: 17px;
  132. min-width: 17px;
  133. }
  134. input[type=radio].ace:checked @{lbl}::before {
  135. content:"\f111";
  136. }
  137. input[type=checkbox].ace.input-lg @{lbl}::before{
  138. border-radius: 4px;
  139. font-size: @font-size-checkbox-large;
  140. height: 24px;
  141. line-height: 21px;
  142. min-width: 24px;
  143. top: auto;
  144. }
  145. input[type=radio].ace.input-lg @{lbl}::before {
  146. font-size: @font-size-radio-large;
  147. height: 24px;
  148. line-height: 22px;
  149. min-width: 24px;
  150. top: auto;
  151. }
  152. /* CSS3 on/off switches */
  153. //use like <input type="checkbox" class="ace ace-switch" /> <span class="lbl"></span>
  154. .enable_switches() when(@enable-switch = true) {
  155. input[type=checkbox].ace.ace-switch {
  156. width: 55px;
  157. height: 25px;
  158. @{lbl} {
  159. margin:0 4px;
  160. min-height:24px;
  161. &::before {
  162. font-family: 'Open Sans';
  163. content: @switch-1-text;
  164. color: #999;
  165. text-shadow: 0 0 0 #999;
  166. font-weight: normal;
  167. font-size: @font-size-switch-1-text;
  168. line-height: 17px;// line-height:21px \9;/*ie9*/
  169. height: 20px;
  170. overflow: hidden;
  171. border-radius: 12px;
  172. background-color: #F5F5F5;
  173. //.box-shadow(~"inset 0px 2px 2px 0px rgba(0,0,0,.2)");
  174. .box-shadow(~"inset 0 1px 1px 0 rgba(0, 0, 0, 0.15)");
  175. border: 1px solid #CCC;
  176. text-align: left;
  177. float: left;
  178. padding: 0;
  179. width: 52px;
  180. text-indent: -21px;// text-indent: -21px \9;
  181. margin-right: 0;
  182. .transition(~"text-indent .3s ease");
  183. top: auto;
  184. }
  185. &::after {
  186. font-family: 'Open Sans';
  187. content: 'III';
  188. font-size: @font-size-switch-1-bar;
  189. font-weight: normal;
  190. letter-spacing: 0;
  191. color: #AAA;
  192. text-shadow: none;
  193. //text-shadow: 0 0 0 #999;
  194. background-color: #FFF;
  195. //text-align: center;
  196. //text-indent: -2px;
  197. border-radius: 100%;
  198. width: 22px;
  199. height: 22px;
  200. line-height: 22px;
  201. text-align: center;
  202. position: absolute;
  203. top: -2px;
  204. left: -3px;
  205. .box-shadow(~"0px 1px 1px 1px rgba(0,0,0,.3)");
  206. //text-shadow:0px 1px 1px rgba(0,0,0,0.3) inset;
  207. .transition(~"left .3s ease");
  208. }
  209. }
  210. &:checked @{lbl} {
  211. &::before {
  212. text-indent: 8px;
  213. color: #FFF;
  214. text-shadow: 0 0 0 #FFF;
  215. background-color: @switch-checked-bg;
  216. border-color: @switch-checked-border;
  217. }
  218. &::after {
  219. left: 34px;
  220. background-color: #FFF;
  221. color: #98A0A5;
  222. //text-shadow: 0 0 0 #465868;
  223. }
  224. }
  225. &.ace-switch-2 @{lbl}::before {
  226. content: @switch-2-text;
  227. }
  228. &.ace-switch-3 @{lbl}::after {
  229. font-family: FontAwesome;
  230. font-size: @font-size-switch-3-text;
  231. line-height: 22px;
  232. content: "\f00d";
  233. top: -1px;
  234. text-shadow: none;
  235. padding: 0;
  236. text-align: center;
  237. color: #BBB;
  238. letter-spacing: 0;
  239. }
  240. &.ace-switch-3:checked @{lbl}::after {
  241. content: "\f00c";
  242. color: #8AB2C9;
  243. text-shadow: none;
  244. }
  245. //switch style 4 & 5
  246. .enable_switch_style_4() when(@enable-switch-style-4 = true) {
  247. &.ace-switch-4 , &.ace-switch-5 {
  248. width: 60px;
  249. @{lbl}::before {
  250. content: @switch-4-text;
  251. //font-family:Arial, Helvetica, sans-serif;
  252. //font-weight:bolder;
  253. font-size: @font-size-switch-4-text;
  254. line-height: 21px;
  255. height: 24px;
  256. overflow: hidden;
  257. //line-height:25px \9;
  258. border-radius: 12px;
  259. display: inline-block;
  260. background-color: @switch4-bg;
  261. border: 1px solid @switch4-bg;
  262. color: #FFF;
  263. width: 56px;
  264. text-indent: -25px;// text-indent: -28px \9;
  265. text-shadow: 0 0 0 #FFF;
  266. display: inline-block;
  267. position: relative;
  268. //margin-right:8px;
  269. box-shadow:none;
  270. .transition(~"all .3s ease");
  271. }
  272. @{lbl}::after {
  273. content: 'III';
  274. font-size: @font-size-switch-4-bar;
  275. position: absolute;
  276. top: 2px;
  277. left: 2px;
  278. letter-spacing: 0;
  279. width: 20px;
  280. height: 20px;
  281. line-height: 19px;
  282. text-shadow: none !important;
  283. color: @switch4-color;
  284. background-color:#FFF;
  285. .transition(~"all .3s ease");
  286. }
  287. &:checked @{lbl} {
  288. &::before {
  289. text-indent: 9px;
  290. background-color: @switch4-checked-bg;
  291. border-color: #468FCC;
  292. }
  293. &::after {
  294. left: 34px;
  295. background-color: #FFF;
  296. color: darken(@switch4-color , 6%);
  297. }
  298. }
  299. }
  300. &.ace-switch-5 @{lbl}::before {
  301. content: @switch-5-text;
  302. }
  303. &.ace-switch-5:checked @{lbl}::before {
  304. text-indent: 8px;
  305. }
  306. }
  307. .enable_switch_style_4();
  308. .enable_switch_style_6() when(@enable-switch-style-6 = true) {
  309. //switch style 6
  310. &.ace-switch-6 {
  311. @{lbl} {
  312. position: relative;
  313. &::before {
  314. font-family: FontAwesome;
  315. content: "\f00d";
  316. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  317. box-shadow: none;
  318. border-width: 0;
  319. font-weight: lighter;
  320. font-size: @font-size-switch-6-text;
  321. border-radius: 12px;
  322. display: inline-block;
  323. background-color: #888;
  324. color: #F2F2F2;
  325. width: 52px;
  326. height: 22px;
  327. line-height: 21px;
  328. text-indent: 32px;
  329. .transition(~"background 0.1s ease");
  330. }
  331. &::after {
  332. content: ''; text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);
  333. position: absolute;
  334. top: 2px;
  335. left: 3px;
  336. border-radius: 12px;
  337. box-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);
  338. width: 18px;
  339. height: 18px;
  340. text-align: center;
  341. background-color: #F2F2F2;
  342. border: 4px solid #F2F2F2;
  343. .transition(~"left 0.2s ease");
  344. }
  345. }
  346. &:checked @{lbl} {
  347. &::before {
  348. content: "\f00c";
  349. text-indent:6px;
  350. color:#FFF;
  351. border-color:@switch6-checked-border;
  352. background-color:@switch6-checked-bg;
  353. }
  354. &::after {
  355. left:32px;
  356. background-color:#FFF;
  357. border:4px solid #FFF;
  358. text-shadow:0 -1px 0 rgba(0, 200, 0, 0.25);
  359. }
  360. }
  361. }
  362. }
  363. .enable_switch_style_6();
  364. .enable_switch_style_7() when(@enable-switch-style-7 = true) {
  365. &.ace-switch-7 {
  366. width:75px;
  367. @{lbl} {
  368. position: relative;
  369. &::before {
  370. content: @switch-7-text;
  371. font-weight: bolder;
  372. font-size: @font-size-switch-7-text;
  373. line-height: 20px;
  374. display: inline-block;
  375. background-color: #FFF;
  376. border: 2px solid #AAA;
  377. border-radius: 0;
  378. box-shadow: none;
  379. color: #AAA;
  380. width: 74px;
  381. height: 26px;
  382. line-height: 22px;
  383. overflow: hidden;
  384. text-indent: 5px;
  385. display: inline-block;
  386. position: relative;
  387. //margin-right:8px;
  388. .transition(~"all 0.2s ease");
  389. }
  390. &::after {
  391. content: '\f00d';
  392. font-family: FontAwesome;
  393. font-size: @font-size-switch-7-bar;
  394. position: absolute;
  395. top: 3px;
  396. left: 39px;
  397. width: 32px;
  398. height: 20px;
  399. line-height: 18px;
  400. text-align: center;
  401. padding: 0;
  402. text-indent: 0;
  403. background-color: #AAA;
  404. color: #FFF;
  405. border-radius: 0;
  406. box-shadow: none;
  407. .transition(~"all 0.2s ease-in-out");
  408. }
  409. }
  410. &:checked @{lbl} {
  411. &::before {
  412. color: @switch7-checked-bg;
  413. background-color: #FFF;
  414. text-indent: -28px;
  415. border-color: @switch7-checked-border;
  416. }
  417. &::after {
  418. left: 3px;
  419. content: '\f00c';
  420. background-color: @switch7-checked-bg;
  421. color: #FFF;
  422. }
  423. }
  424. }
  425. }
  426. .enable_switch_style_7();
  427. }
  428. //any custom text
  429. input[type=checkbox].ace.ace-switch @{lbl}[data-lbl]::before {
  430. content: attr(data-lbl);
  431. }
  432. input[type=checkbox].ace.ace-switch.btn-empty @{lbl}::after {
  433. content: "";
  434. }
  435. input[type=checkbox].ace.ace-switch.btn-rotate @{lbl}::after {
  436. content: "\2261";// the 3 line (menu) character
  437. line-height: 20px;
  438. font-size: @font-size-switch-rotated-bar;
  439. }
  440. input[type=checkbox].ace.ace-switch-4.btn-rotate @{lbl}::after,
  441. input[type=checkbox].ace.ace-switch-5.btn-rotate @{lbl}::after {
  442. line-height: 17px;
  443. }
  444. //flat, square
  445. input[type=checkbox].ace.ace-switch.btn-flat @{lbl}::before,
  446. input[type=checkbox].ace.ace-switch.btn-flat @{lbl}::after {
  447. border-radius: 0 !important;
  448. }
  449. input[type=checkbox].ace.ace-switch.ace-switch-4 , input[type=checkbox].ace.ace-switch.ace-switch-5 {
  450. @{lbl}::before {
  451. text-indent: -24px;
  452. }
  453. &:checked @{lbl}::before {
  454. text-indent: 7px;
  455. }
  456. }
  457. }
  458. .enable_switches();
  459. input.ace @{lbl} {
  460. .checkbox-paddings() {// a little paddings for .lbl
  461. .checkbox-paddingX (@index) when (@index >= 0) {
  462. &.padding-@{index}::before {
  463. margin-right: unit(@index,px);
  464. }
  465. .checkbox-paddingX(@index - 2);
  466. }
  467. .checkbox-paddingX(16);
  468. }
  469. .checkbox-paddings();
  470. }
  471. }
  472. .enable_checkbox();