【问题标题】:select box with images in Angular 5Angular 5中带有图像的选择框
【发布时间】:2019-04-09 21:36:35
【问题描述】:

我在 Angular 5 和 bootstrap 3 中使用了一个选择元素。我认为它是一个 WebForms / Bootstrap 组件。是否可以将图像附加到不同的选项?也许使用 CSS?

           <select (change)="course.active = !course.active"
                    name="myselect">
                <option [selected]="course.active" >
                    Option 1
                </option>
                <option [selected]="!course.active" >
                    Option 2
                </option>
            </select>    

【问题讨论】:

    标签: angular twitter-bootstrap-3


    【解决方案1】:


    这是一个重复的问题,您可以在那里找到答案:

    Adding images with option tag
    How to add images in select list?
    Image in SELECT element

    您不能在&lt;option&gt; 内添加图像,DOM 不允许,&lt;option&gt; 标记只接受纯文本...所以是的,您需要使用 CSS 和 style="background-image" 属性添加图像才能使其工作.

    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-02
      • 1970-01-01
      • 2015-01-09
      • 2013-05-20
      • 1970-01-01
      • 2018-08-29
      • 2015-08-04
      相关资源
      最近更新 更多