My Location

Mar 23, 2009

Select border styling in IE

OK, so you can’t directly style the border of the SELECT element in IE, but if you’re using absolute positioning you can wrap it in a DIV, do the positioning and border on the DIV, then set a negative margin on the SELECT itself. I found that negative 1 pixel is right for drop-down selects, and negative 3 pixels is right for selects with a non-default size. Sample code below.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<style type="text/css">
#select1,#select2 {position:absolute;left:100px;border:1px solid #666;}
#select1 {top:100px;}
#select2 {top:150px;}
.drop {margin:-1px;}
.nodrop {margin:-3px;}
</style>
</head>

<body>

<div id="select1">
<select class="drop">
<option>One Hundred</option>
<option>Two Hundred</option>
<option>Three Hundred</option>
</select>
</div>

<div id="select2">
<select class="nodrop" size="3">
<option>One Hundred</option>
<option>Two Hundred</option>
<option>Three Hundred</option>
</select>
</div>

</body>
</html>

No comments:

Post a Comment