Semantic UI dropdown - display image as icon?

主宰稳场 提交于 2019-12-11 05:53:59

问题


In https://jsfiddle.net/hodtfkys/3/ , how can I get it to always display the image as shown in http://jsfiddle.net/t9vfxo5t/ , not just when the user drops down the list?

Image only when dropdown clicked:

<div class='ui icon selection dropdown'>
  <input name='DropDownListCategoryClone' type='hidden'> <i class='dropdown icon'></i>
  <div class='default text'>
    Male
  </div>
  <div class='menu'>
    <div class='item' data-text='Male' data-value='male'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Male-icon.png' style='width:20px;'> Male
    </div>
    <div class='item' data-text='Female' data-value='female'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Female-icon.png' style='width:20px;'> Female
    </div>
  </div>
</div>

Icon always displaying:

<div class="ui selection dropdown">
    <input type="hidden" name="language">
    <i class="dropdown icon"></i>
    <div class="default text">Select language</div>
    <div class="menu">
        <div class="item" data-value="gb"><i class="gb flag"></i>English</div>
        <div class="item" data-value="es"><i class="es flag"></i>Spanish</div>
    </div>
</div>

回答1:


Hi its seems like you are using the data-text='Male' and data-text='Female' which is creating the issue.Removing it will solve the issue, updated code given below.

    <div class='ui icon selection dropdown'>
  <input name='DropDownListCategoryClone' type='hidden'>
  <i class='dropdown icon'></i>
  <div class='default text'> Select Gender</div>
  <div class='menu'>
    <div class='item' data-value='male'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Male-icon.png' style='width:20px;'> Male
    </div>
    <div class='item' data-value='female'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Female-icon.png' style='width:20px;'> Female
    </div>
  </div>
</div>


来源:https://stackoverflow.com/questions/42432040/semantic-ui-dropdown-display-image-as-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!