[英]How to hide div in one css file but show it in another css file
I have a basic front end auth login react component page that loads when the page is first rendered.我有一个基本的前端身份验证登录反应组件页面,该页面在首次呈现页面时加载。 upon successful login:
登录成功后:
visibility hidden
in login.css
and visibility:visible
in app.css
.visibility hidden
在login.css
和visibility:visible
在app.css
中的可见性。opacity:0
in login.css and opacity:100
in app.css.opacity:0
,在 app.css 中尝试了opacity:100
。 as well as some other trouble shooting css that didn't work.login.css
is overriding the app.css
no matter what.login.css
似乎都覆盖了app.css
。 I am new to this so sorry if this is a dumb question just really need some help thank you in advance.我是新手,如果这是一个愚蠢的问题,我真的很抱歉,真的需要一些帮助,提前谢谢你。
To directly address your question, the CSS property you want to be using is display
and set it to none
.要直接解决您的问题,您要使用的 CSS 属性是
display
并将其设置为none
。 If that still doesn't seem to work, check the specificity of your selector and verify that you're selecting the intended element.如果这似乎仍然不起作用,请检查选择器的特异性并验证您是否选择了预期的元素。 As a last resort use
!important
in your attribute to override all styles.作为最后的手段,在您的属性中使用
!important
来覆盖所有样式。
Since you're using React though, I highly recommend that you don't depend on CSS for this but rather use conditional rendering, eg由于您使用的是 React,我强烈建议您不要依赖 CSS,而是使用条件渲染,例如
return (
<div>
{loggedIn ? (
User dashboard or whatever...
) : (
Display login form
)}
</div>
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.