jQuery styling Selectbox

Preview:
 



HTML

Code

<select name="test">  
  <option value="Click me">Click me</option>  
  <option value="Hasanli Design">Hasanli Design</option>  
  <option value="jQuery Plugin">jQuery Plugin</option>  
  <option value="a Stateful UI Widget">a Stateful UI Widget</option>  
  </select>  


CSS

Code
  
.selectboxit-container {  
  position: relative;  
  display: inline-block;  
  vertical-align: top;  
}  
.selectboxit-container * {  
  font: 14px Helvetica, Arial;  
  -webkit-touch-callout: none;  
  -webkit-user-select: none;  
  -khtml-user-select: none;  
  -moz-user-select: -moz-none;  
  -ms-user-select: none;  
  -o-user-select: none;  
  user-select: none;  
  outline: none;  
  white-space: nowrap;  
}  
.selectboxit-container .selectboxit {  
  width: 220px; /* Width of the dropdown button */  
  cursor: pointer;  
  margin: 0;  
  padding: 0;  
  border-radius: 6px;  
  overflow: hidden;  
  display: block;  
  position: relative;  
}  
.selectboxit-container span, .selectboxit-container .selectboxit-options a {  
  height: 30px; /* Height of the drop down */  
  line-height: 30px; /* Vertically positions the drop down text */  
  display: block;  
}  
.selectboxit-container .selectboxit:focus {  
  outline: 0;  
}  
.selectboxit.selectboxit-disabled, .selectboxit-options .selectboxit-disabled {  
  opacity: 0.65;  
  filter: alpha(opacity=65);  
  -webkit-box-shadow: none;  
  -moz-box-shadow: none;  
  box-shadow: none;  
  cursor: default;  
}  
.selectboxit-text {  
  text-indent: 5px;  
  overflow: hidden;  
  text-overflow: ellipsis;  
  float: left;  
}  
.selectboxit .selectboxit-option-icon-container {  
  margin-left: 5px;  
}  
.selectboxit-container .selectboxit-options {  
  -moz-box-sizing: border-box;  
  box-sizing: border-box;  
  min-width: 100%;
  *width: 100%;  
  margin: 0;  
  padding: 0;  
  list-style: none;  
  position: absolute;  
  overflow-x: hidden;  
  overflow-y: auto;  
  cursor: pointer;  
  display: none;  
  z-index: 9999999999999;  
  border-radius: 6px;  
  text-align: left;  
  -webkit-box-shadow: none;  
  -moz-box-shadow: none;  
  box-shadow: none;  
}  
.selectboxit-option .selectboxit-option-anchor{  
  padding: 0 2px;  
}  
.selectboxit-option .selectboxit-option-anchor:hover {  
  text-decoration: none;  
}  
.selectboxit-option, .selectboxit-optgroup-header {  
  text-indent: 5px;
  margin: 0;  
  list-style-type: none;  
}  
.selectboxit-option-first {  
  border-top-right-radius: 6px;  
  border-top-left-radius: 6px;  
}  
.selectboxit-optgroup-header + .selectboxit-option-first {  
  border-top-right-radius: 0px;  
  border-top-left-radius: 0px;  
}  
.selectboxit-option-last {  
  border-bottom-right-radius: 6px;  
  border-bottom-left-radius: 6px;  
}  

.selectboxit-optgroup-header {  
  font-weight: bold;  
}  

.selectboxit-optgroup-header:hover {  
  cursor: default;  
}  

.selectboxit-arrow-container {  
  /* Positions the down arrow */  
  width: 30px;  
  position: absolute;  
  right: 0;  
}  

.selectboxit .selectboxit-arrow-container .selectboxit-arrow {  
  margin: 0 auto;  
  position: absolute;  
  top: 50%;  
  right: 0;  
  left: 0;  
}  

.selectboxit .selectboxit-arrow-container .selectboxit-arrow.ui-icon {  
  top: 30%;  
}  

.selectboxit-option-icon-container {  
  float: left;  
}  

.selectboxit-container .selectboxit-option-icon {  
  margin: 0;  
  padding: 0;  
  vertical-align: middle;  
}  

.selectboxit-option-icon-url {  
  width: 18px;  
  background-size: 18px 18px;  
  background-repeat: no-repeat;  
  height: 100%;  
  background-position: center;  
  float: left;  
}  

.selectboxit-rendering {  
  display: inline-block !important;  
  *display: inline !important;  
  zoom: 1 !important;  
  visibility: visible !important;  
  position: absolute !important;  
  top: -9999px !important;  
  left: -9999px !important;  
}  

.jqueryui .ui-icon {  
  background-color: inherit;  
}  

.jqueryui .ui-icon-triangle-1-s {  
  background-position: -64px -16px;  
}  

.selectboxit-btn {  
  background-color: #f5f5f5;  
  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);  
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));  
  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);  
  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);  
  background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);  
  background-repeat: repeat-x;  
  border: 1px solid #cccccc;  
  border-color: #e6e6e6 #e6e6e6 #bfbfbf;  
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);  
  border-bottom-color: #b3b3b3;  
}  

.selectboxit-btn.selectboxit-enabled:hover,  
.selectboxit-btn.selectboxit-enabled:focus,  
.selectboxit-btn.selectboxit-enabled:active {  
  color: #333333;  
  background-color: #e6e6e6;  
}  

.selectboxit-btn.selectboxit-enabled:hover,  
.selectboxit-btn.selectboxit-enabled:focus {  
  color: #333333;  
  text-decoration: none;  
  background-position: 0 -15px;  
}  

.selectboxit-default-arrow {  
  width: 0;  
  height: 0;  
  border-top: 4px solid #000000;  
  border-right: 4px solid transparent;  
  border-left: 4px solid transparent;  
}  

.selectboxit-list {  
  background-color: #ffffff;  
  border: 1px solid #ccc;  
  border: 1px solid rgba(0, 0, 0, 0.2);  
  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);  
  -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);  
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);  
}  

.selectboxit-list .selectboxit-option-anchor {  
  color: #333333;  
}  

.selectboxit-list > .selectboxit-focus > .selectboxit-option-anchor {  
  color: #ffffff;  
  background-color: #0081c2;  
  background-image: -moz-linear-gradient(top, #0088cc, #0077b3);  
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));  
  background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);  
  background-image: -o-linear-gradient(top, #0088cc, #0077b3);  
  background-image: linear-gradient(to bottom, #0088cc, #0077b3);  
  background-repeat: repeat-x;  
}  

.selectboxit-list > .selectboxit-disabled > .selectboxit-option-anchor {  
  color: #999999;  
}


jQuery

Code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>  
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>  
<script src="http://gregfranko.com/jquery.selectBoxIt.js/js/jquery.selectBoxIt.min.js"></script>  
  <script>  
  $(function() {  

  var selectBox = $("select").selectBoxIt();  

  });  
  </script>  

Total comments: 1
Altay Hasanli
Please add your comment
Name *:
Email:
Code *: