简体   繁体   English

如何在jQuery Mobile中为各个select.option元素指定字体系列?

[英]How to specify font-family for individual select.option elements in jquery mobile?

A typical jQuery mobile custom select menu is coded like this: 典型的jQuery移动自定义选择菜单的编码如下:

<div class="ui-field-contain">
    <select id="mymenu" data-native-menu="false">
        <option data-placeholder="true">Choose one...</option>
        <option value="1">The 1st Option</option>
        <option value="2">The 2nd Option</option>
        <option value="3">The 3rd Option</option>
    </select>
</div>

The framework then turns that into this: 然后,框架将其转换为:

<ul id="mymenu-listbox" class="ui-selectmenu-list ui-listview">
   <li class="" data-option-index="1" data-icon="false" role="option" aria-selected="false">
        <a class="ui-btn" href="#">The first option</a>
<!--et cetera-->

I'm trying to create a select menu where the user selects a custom font-family. 我正在尝试创建一个选择菜单,用户可以在其中选择自定义字体系列。 Obviously, I'd like to be able to visualise each option in the list, but inline styling the <option> tags isn't working. 显然,我希望能够可视化列表中的每个选项,但是对<option>标记进行内联样式无法正常工作。 How can I achieve this? 我该如何实现?

With help from @Mr Lister, the following sass works: 在@Mr Lister的帮助下,以下sass起作用了:

/*first child is an invisible screen*/
#text-font-list-listbox, #heading-font-list-listbox > ul >
  li:nth-child(2) > a
    font-family: Georgia,serif
  li:nth-child(3) > a
    font-family: Palatino,serif
  li:nth-child(4) > a
    font-family: Times,serif
  /*etc*/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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