如何在选择选项的HTML标签中应用字体系列 [英] How to apply font family in HTML tag of select option
本文介绍了如何在选择选项的HTML标签中应用字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在< select>< option>
标记中应用了字体系列,但是它对任何选项都不起作用
I am applying Font family in <select><option>
tag but it is not working any option guys
我的代码:
<select name="t1_font" class="form-control" >
<option style="font-family: Font-familly path');">Font-family Name</option>
</select>
我正在使用的真实代码:
My real code that I am using :
<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>
这篇关于如何在选择选项的HTML标签中应用字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文