最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set height Or Padding in select box (dropdown box) for safari and chrome? - Stack Overflow

programmeradmin3浏览0评论

I want to set height or width in selectbox .

<?php $subjectList=array('0'=>'Questions','1'=>'Feedback / Suggestions','2'=>'Location Owner Inquiry' ,'3'=>'Other');?>

<select name="vSubject" data-errormessage-value-missing="Select Reason!" id="vSubject"  >
   <option value="" >-Select One-</option>
   <?php foreach($subjectList as $r=>$k) { ?>
         <option value="<?php echo $r?>" ><?php echo $k?></option>
   <?php }?>
</select>

Padding and height is not working in SAFARI. So suggest some solution.

I want to set height or width in selectbox .

<?php $subjectList=array('0'=>'Questions','1'=>'Feedback / Suggestions','2'=>'Location Owner Inquiry' ,'3'=>'Other');?>

<select name="vSubject" data-errormessage-value-missing="Select Reason!" id="vSubject"  >
   <option value="" >-Select One-</option>
   <?php foreach($subjectList as $r=>$k) { ?>
         <option value="<?php echo $r?>" ><?php echo $k?></option>
   <?php }?>
</select>

Padding and height is not working in SAFARI. So suggest some solution.

Share Improve this question edited Jul 28, 2014 at 10:21 Ronak Patel asked Jul 28, 2014 at 10:16 Ronak PatelRonak Patel 3,4544 gold badges22 silver badges31 bronze badges 2
  • possible duplicate of stackoverflow./questions/13252835/… – Suresh Ponnukalai Commented Jul 28, 2014 at 10:28
  • And what about 'option' ? If I want to set height or padding, thn ? – Ronak Patel Commented Jul 28, 2014 at 10:47
Add a ment  | 

4 Answers 4

Reset to default 3

Did you try this CSS for your drop down?

overflow: hidden;
border: none;
outline: none;
-webkit-appearance: none;

For Safari you can try

-webkit-appearance: menulist-button;

so that width and height will work (link)

then you can use background,font-family,padding etc to further enchant your custom select tag. It worked for me in Safari/Chrome/FF ...

EDIT:

Editing option tag is not that easy. You can use the css below but everything is not customisable unfortunately

select option {
    margin:40px;
    background: rgba(0,0,0,0.3);
    color:#fff;
    text-shadow:0 1px 0 rgba(0,0,0,0.4);
}       

sources: 1,2

Fiddle here Use a bination of text-indent and line-height to create the illusion of padding. Works in Safari.Should work in IE as well.

#vSubject {
    text-indent:15px; line-height:28px;
}

try like this.

select {
 width: 170px; 
 height: 25px;
 -webkit-appearance: menulist-button;
}
select { line-height : 28px; float : left; }
发布评论

评论列表(0)

  1. 暂无评论