Last active
August 29, 2015 14:03
-
-
Save cfxd/d282f3322a919bab5a35 to your computer and use it in GitHub Desktop.
This will style WooCommerce's ChosenJS select boxes on the WooCommerce checkout page to match your existing Bootstrap form styles (assuming you've made any style changes in LESS) and even replaces the default background images with Bootstrap's built in Glyphicons.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first some helpful mixins | |
.abs { | |
position: absolute; | |
} | |
.rel { | |
position: relative; | |
} | |
.position(@top; @right; @bottom; @left) { | |
top: @top; | |
right: @right; | |
bottom: @bottom; | |
left: @left; | |
} | |
.lh(@line-height) { | |
line-height: @line-height; | |
} | |
// now the ChosenJS styles | |
.chosen-container { | |
.woocommerce-checkout .form-row & { | |
.chosen-single { | |
&:extend(.form-control); | |
.box-shadow(none); | |
span { | |
margin: 0; | |
} | |
div { | |
.position(@padding-base-vertical; @padding-base-horizontal; @padding-base-vertical; auto); | |
.size(16px; auto); | |
b { | |
background: transparent !important; | |
&:extend(.rel); | |
.glyphicon; | |
.glyphicon-chevron-down; | |
&:before { | |
&:extend(.abs); | |
.position(0; 0; auto; auto); | |
.lh(@input-height-base - (@padding-base-vertical * 2)); | |
} | |
} | |
} | |
} | |
.chosen-drop { | |
.glyphicon-search; | |
&:before { | |
&:extend(.abs); | |
.position((@padding-base-vertical + 1); ((2 * @padding-base-horizontal) + 1); auto; auto); | |
z-index: 1020; | |
height: ((@input-height-base - 8) - (2 * @padding-base-vertical)); | |
.lh((@input-height-base - 8) - (2 * @padding-base-vertical)); | |
color: @text-color; | |
} | |
} | |
&.chosen-with-drop .chosen-drop { | |
.glyphicon; | |
.chosen-results, .chosen-search { | |
font-family: @font-family-base; | |
} | |
} | |
} | |
.chosen-results { | |
margin: 0 @padding-base-horizontal (2 * @padding-base-vertical) 0; | |
padding: 0 0 0 @padding-base-horizontal; | |
li { | |
padding: 4px @padding-base-horizontal; | |
.lh(14px); | |
&.highlighted { | |
background: @component-active-bg; | |
} | |
&.no-results { | |
background: @input-bg-disabled; | |
} | |
em { | |
//change the search string appearance in results | |
font-weight: 700; | |
} | |
} | |
} | |
&-single { | |
.chosen-search { | |
padding: 0 @padding-base-horizontal; | |
} | |
.chosen-drop { | |
margin-top: -2px; | |
border-top-radius: 0; | |
border-bottom-radius: @input-border-radius; | |
.box-shadow(none); | |
border: none; | |
} | |
.woocommerce-checout .form-row & .chosen-search, .chosen-search { | |
input, input[type=text] { | |
&:extend(.form-control); | |
height: (@input-height-base - 8); | |
.lh((@input-height-base - 8) - (2 * @padding-base-vertical)); | |
border: 1px solid @input-border; | |
font-family: @font-family-base; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment