简体   繁体   中英

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

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.

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 combination 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; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM