CSS 不适用于映射 Font Awesome 图标

标签 css reactjs sass

我有一个 react /sass 问题。当我使用 .map 为文件格式创建多个很棒的字体图标时,样式仅应用于映射的最后一个元素。映射看起来像这样:

filelist.map((ext) => {
              return(
                (ext != 'docx')
                ? ext != 'txt' 
                  ? <span className='col col-xs-6'><i key={ext} className={'fa fa-file-'.concat(ext).concat('-o red')}></i></span>
                  : <span className='col col-xs-6'><i key={ext} className={'fa fa-file-text-o yellow'}></i></span>
                : <span className='col col-xs-6'><i key={ext} className={'fa fa-file-word-o blue'}></i></span>
              );
            })

因此,如果 filelist 是 ['word', 'txt'] 样式将仅适用于 txt 图标。

这是正在应用的 SASS 文件。

.fa-file-word-o:hover 
  font-size: 1.7em
  transition: all 500ms ease-in-out

.fa-file-pdf-o:hover 
  font-size: 1.7em
  transition: all 500ms ease-in-out

.fa-file-text-o:hover 
  font-size: 1.7em
  transition: all 500ms ease-in-out

so in this case: the single pdf works fine and the word doc enlarge. but the text and pdf on the multi file type line do not enlarge on hover.

最佳答案

React Documentation

确保你所有的 key 都是唯一的

关于CSS 不适用于映射 Font Awesome 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49655877/

相关文章:

javascript - 在 React 门户中呈现 iFrame

ruby - OS X 上的 RVM、FSEvents 和 CarbonCore

css - SASS 中的媒体查询编译但不显示

javascript - 单击提交后平滑滚动到 DIV

javascript - TypeScript 在对象中查找键时出现问题

javascript - 如何将 Bootstrap 模板集成到 Rails 4 元素中

unit-testing - jsdom 9.1+ 在聚焦节点时不设置 document.activeElement

css - 当其容器/父元素悬停时将 css 样式应用于元素 Angular

CSS 伪元素的 jQuery .click() 事件 ( :before/:after)?

css - 在 css3 中制作这个(梯形)形状的最佳方法