html - 如何在 Vue 组件中将一个图标覆盖在另一个图标之上?

标签 html css vue.js

我有一个 Vue 组件:

<template>
    <span>
        <i  class="fas fa-file-pdf icon_styling"
            v-bind:style="`color: ` +  fileStatusColor()" ></i>
        <i  class="fas fa-paperclip icon_addition_styling" 
            v-if={{showIcon}}></i>
        {{ mytext }}
    </span>
</template>

我想在另一个图标上显示回形针。

不幸的是,How to overlay one div over another div 的解决方案不起作用,因为 position:absolute 在整个页面上定位自己,而不是在我的 vue 组件内定位。

我的第二个想法是在图标上使用负边距,但这也会移动文本。

有没有办法用 html5/css 让图标覆盖在我的 vue 组件中?

最佳答案

FontAwesome居然支持stacked icons .

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">

<span class="fa-stack fa-2x">
  <i class="fas fa-file fa-stack-2x icon_styling" style="color: crimson;"></i>
  <i class="fas fa-paperclip fa-stack-1x icon_addition_styling" style="color: white;"></i>
</span>

关于html - 如何在 Vue 组件中将一个图标覆盖在另一个图标之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54555611/

相关文章:

javascript - Nuxt JS SSR 标题未定义

javascript - 从右向左滑动div但只有一个div

html - 使用 float 属性对齐 DIV

html - 用于更改表格单元格内容的 CSS 复选框

html - 页脚看起来不像我想要的。 Bootstrap

javascript - 在向另一个组件发出 http 请求时保持 react 性

javascript - 如何向 taginput 元素添加验证?

html - 在 ul li 的第二级悬停时显示 ul li 的第三级

html - Wordpress 菜单项视频灯箱

css - line-clamp 在 Firefox 上不起作用?