【发布时间】:2019-07-28 17:41:12
【问题描述】:
我现在正在开发一个简单的 react 组件,而我通常在样式表中使用的 CSS:hover 并且始终有效,但实际上在该组件的任何地方都不起作用。我试图了解可能导致它的原因。将不胜感激任何帮助。这是组件。
import React, { Component } from 'react';
import './index.css';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
class MenuSearchOutput extends Component {
render(){
return(
<div className="menuSearchOutputRoot">
<div className="menuSearchOutputVoidLeft"></div>
<div className="menuSearchOutputLeft">Burgers</div>
<div className="menuSearchOutputRight">
<FontAwesomeIcon id="menuSearchElementEdit" icon={faEdit}/>
<FontAwesomeIcon id="menuSearchElementDelete" icon={faTrash}/>
</div>
</div>
)
}
}
export default MenuSearchOutput;
.menuSearchOutputRoot{
display:flex;
flex-direction:row;
align-items:center;
height:50px;
width:100%;
background-color:lightcyan;
border-bottom: solid cyan 1px;
}
.menuSearchOutputVoidLeft{
height:50px;
width:2%;
}
.menuSearchOutputLeft{
display:flex;
flex-direction:column;
justify-content:center;
align-items:center;
height:32px;
width: 68%;
background-color:white;
color:black;
}
.menuSearchOutputRight{
display:flex;
flex-direction:row;
justify-content:space-evenly;
align-items:center;
height:50px;
width:30%;
}
#menuSearchElementDelete:hover{
opacity:0.8;
cursor:pointer;
}
#menuSearchElementEdit:hover{
opacity:0.8;
cursor:pointer;
}
【问题讨论】:
-
您可以编辑您的问题以添加您的
index.CSS吗? -
对我来说一切都很好:codesandbox.io/s/ancient-bush-hfby5