我在<select><option>
标签中应用了字体家族,但是它在任何选项中都无法正常工作
我的代码:
<select name="t1_font" class="form-control" >
<option style="font-family: Font-familly path');">Font-family Name</option>
</select>
我正在使用的真实代码:
<div class="col-sm-4">
<?php $fonts=glob(FONT_URL.'*'); //print_r($fonts); ?>
<?php if (!empty($fonts)): $i=0;?>
<?php foreach ($fonts as $font):
$font_arr= explode('/',$font); $font_string =substr($font_arr[3], 0, -4);?>
<style>
@font-face {
font-family: <?php echo $font_string ?>;
src: url('<?php echo $font ?>');
}
</style>
<?php $i++;
endforeach ?>
<?php endif ?>
<b>Family</b><br>
<select name="t1_font" class="form-control" >
<?php if (!empty($fonts)): ?>
<?php foreach ($fonts as $font): $font_arr= explode('/',$font); $font_string =substr($font_arr[3], 0, -4); ?>
<option style="font-family: <?php echo $font_string ?>;src: url('<?php echo base_url($font) ?>');" value="<?php echo $font_arr[3] ?>" <?php if(!empty($default_data_param->text1))
{if($font_arr[3]== $default_data_param->text1_font_file){ echo'selected';}}?> ><?php echo ucfirst($font_string) ?></option>
<?php endforeach ?>
<?php endif ?>
</select>
</div>
太简单
看看这个演示
#select1 {
font-family: 'sans-serif';
}
#select2 {
font-family: tahoma;
}
#select3 {
font-family: monospace;
}
<select id="select1">
<option>OPTION 1</option>
<option>OPTION 2</option>
<option>OPTION 3</option>
</select>
<br/>
<select id="select2">
<option>OPTION 1</option>
<option>OPTION 2</option>
<option>OPTION 3</option>
</select>
<br/>
<select id="select3">
<option>OPTION 1</option>
<option>OPTION 2</option>
<option>OPTION 3</option>
</select>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句