Reputation: 90
I've successfully style a select box. However, I have trouble handling the overflow issue. Please see the image.
Whenever i try too long into the select field, the text cover the dropdown icon(i use an background image for that). Anybody know how to make dropdown icon to cover the text if the text field is too long? I really appreciate it!
Upvotes: 3
Views: 1482
Reputation: 929
easy
HTML
<select>
<option>blabòaablabmalkbmakbvnozeetjztjzrjdjttjtjetjtjetja</option>
</select>
CSS
select {
max-width:200px; /* just my style, edit to what you want */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image:url('http://pediatrics.evms.edu/assets/images/icon_arrow_down.png'); /* the first icon on google :) replace with your own */
background-repeat:no-repeat;
background-position:right;
padding-right:15px; /* this do the trick */
}
Upvotes: 2
Reputation: 16223
You can set the padding
, like:
input[type="text"] // Or whatever selector you're using
{
padding-right: 15px;
}
So the text doesn't overlap with your background image...
Demo: http://jsfiddle.net/darkajax/nekdS/
Upvotes: 2
Reputation: 165
Add something like an ID to it then do this:
CSS:
#id {
border: 2px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
border-color: black;
and so on...
}
Upvotes: 0
Reputation: 696
you should first start with a to correct in every browser. then add the padding to let the arrow be alone in the right side. try it.
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
and then add your own styles, such as background border, padding, box-shadow and whatever....
good luck!
Upvotes: 2