[英]How to change style of an element onClick at another element REACT?
I want to change .page-header when i click on standard-basic.我想在单击标准基本时更改 .page-header。 I tried to do this:我试图这样做:
#standard-basic:focus ~ .page-header{
display: none;
}
But it can't help me.但它帮不了我。 How can change style of page-header in react or maybe just in js?如何在反应中或仅在 js 中更改页眉的样式? I use functional component我使用功能组件
<span id="pageHeader" className="page-header">TechPrice</span>
<form
className={props.classes.root}
noValidate
autoComplete="off"
className="search-form"
>
<TextField className="textField" id="standard-basic" label="Поиск" />
<SearchIcon className="search-icon" />
</form>
I think you need to use style object and set display prop to none depend on some state我认为您需要使用样式对象并将显示道具设置为无取决于某些状态
Example:例子:
<span id="pageHeader" style={{"display": `isVisible ? "block" : "none"`}}>TechPrice</span>
There is no parent selector in CSS/CSS3
. CSS/CSS3
没有父选择器。
Please read this topic: Is there a CSS parent selector?请阅读此主题: 是否有 CSS 父选择器?
To achieve your goal you have to use JavaScript/React/any other framework/library
为了实现你的目标,你必须使用JavaScript/React/any other framework/library
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.