Styling a Chosen select to fit Bootstrap 3 better
Join the DZone community and get the full member experience.
Join For Freeone project that i'm currently working on is an internal business application that's using stock bootstrap 3 . i needed a searchable select box and chosen fitted the bill, so i'm using that.
however, the default styles for the chosen select box differ slightly from bootstrap. the most noticeable being the height of the control.
to fix this, i added this css:
.chosen-container-single .chosen-single { height: 30px; border-radius: 3px; border: 1px solid #cccccc; } .chosen-container-single .chosen-single span { padding-top: 2px; } .chosen-container-single .chosen-single div b { margin-top: 2px; }
i also noticed that a focussed bootstrap 3 element has a blue outline, but the chosen select doesn't. to fix this, i added:
.chosen-container-active .chosen-single, .chosen-container-active.chosen-with-drop .chosen-single { border-color: #ccc; border-color: rgba(82, 168, 236, .8); outline: 0; outline: thin dotted \9; -moz-box-shadow: 0 0 8px rgba(82, 168, 236, .6); box-shadow: 0 0 8px rgba(82, 168, 236, .6) }
before:
after:
update: brian ridley pointed me at bootstrap-chosen which is much more comprehensive.
Published at DZone with permission of Rob Allen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Unlocking the Power of AIOps: Enhancing DevOps With Intelligent Automation for Optimized IT Operations
-
Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
-
Getting Started With the YugabyteDB Managed REST API
-
Top 10 Pillars of Zero Trust Networks
Comments