"Concealing a div in one CSS file while revealing it in a separate CSS file: a step-by

When my basic front end auth login react component page loads for the first time, I have an issue where a form appears on the login side of things that I only want to show once the app side has rendered upon successful login.

  • Once logged in, it should render the app component.
  • I have separate CSS files for login and app styling: login.css and app.css.
  • In my HTML document, I added code for the form to submit user input for the app, but I don't want this form to be visible on the login side.
  • Despite trying various methods like setting visibility hidden in login.css and visibility:visible in app.css, or using opacity:0 in login.css and opacity:100 in app.css, the login.css seems to override the app.css no matter what I try.

This is all new to me, so apologies if this is a simple question. Any help would be greatly appreciated. Thank you!

Answer №1

To directly answer your query, the CSS attribute you should utilize is display and designate it as none. If this does not yield the desired result, assess the specificity of your selector to confirm you are targeting the correct element. As a final option, incorporate !important in your property to override all existing styles.

Considering you are employing React, I strongly advise against relying on CSS for this action; instead, opt for conditional rendering, such as:

return (
  <div>
    {loggedIn ? (
      User dashboard or any other content...
    ) : (
      Display login form
    )}
  </div>
);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to automatically fill HTML code with a value from a input on the previous page stored in the URL parameters

Seeking assistance with incorporating a custom query string value from the URL into the default value of my HTML code. I need guidance on how to substitute the placeholder text "URL VALUE" with the actual value retrieved from the URL. https://i.sstatic.ne ...

Error in React+Redux: Trying to access the "address" property of a null value is not permitted

I am new to using react and encountering an issue with my ecommerce app. The app runs smoothly until I log out and then log back in at the shipping address page, which triggers the following error: TypeError: Cannot read property 'address' of nu ...

Determining the element type that was clicked using Angular

Is there a way in Angular to determine the type of element that was clicked? I have successfully implemented this functionality using jQuery, but I'm unsure how to achieve the same outcome in an Angular project. // Click action $(".contactlist").on(" ...

Navigating THREE.js Editor: Leveraging the main script within a sample illustration

One of the tools I can utilize is the THREE.js editor found at . Opening an example app like PONG is also possible. Interactive animation can be activated by clicking on Play in the menu bar, and deactivated by clicking on Stop. My goal is to edit the Mai ...

Mastering Dropdown Navigation and Value Setting in Angular

I am facing a challenge with two components named ComponentA and ComponentB. In ComponentB, there is a link that, when clicked, should navigate to ComponentA and send specific data to it. This data needs to be displayed in the dropdown options of Component ...

Error: React-Redux Provider is being called incorrectly

I am currently working on a small application to get familiar with using Redux Toolkit. My understanding of React/Redux mainly comes from an outdated Udacity course. Although the error message lists the top 3 reasons for this particular error, none of the ...

Injecting properties into Supabase filtering - VUE3 and Supabase integration

Attempting to pass a prop to the .like filter in a Supabase function. Since .like requires % in the value, I'm unsure how to pass the prop through. See the code snippet below: const fetchData = async () => { const { data, error } = await supabase ...

Dynamic loading in React Plugin Architecture allows for flexibility in organizing and incorporating

My goal is to develop a Single Page Application on the client side that incorporates a plugin architecture. The requirement is for users to be able to place a package in a designated folder, which will then be loaded by the server after a restart. These pl ...

Using $window.print() in angularjs results in the print preview displaying an empty page

Encountering a strange issue where using $window.print in angularjs results in only the date, page name, page number, and url appearing on the printed page. The rest of the content is missing even though the original page has plenty of it. I suspect the p ...

Stylish tag colors in ExtJS 3 SuperBoxSelect

My SuperBoxSelect element is being populated from a remote store. I am looking to assign a different color to each tag when it is selected. The color value for each tag comes from the store. Currently, I am attempting to achieve this by using the followi ...

Invert the order of the array in the JavaScript variable containing the JSON data

I have a JSON array stored in a variable in the following format: {"info": [ {"typeid": "877", "recid": "10", "repeaterid": "0", "pageid": "26966", "maxrecords": "1"}, {"typeid": "877", "recid": "11", "repeaterid": "0", "pageid": "26966", "maxrecords ...

Demonstrating the transformation of child elements into parent elements through angular 6 ngFor

I have a JSON array dataset where each object may contain nested arrays. In order to display the inner nested array elements as part of the parent array using Angular's NgFor, I need to format the input like this: [{ 'id': 1, 'tit ...

What is the best way to layer elements with css Grid?

I've created an app using Angular where I need to design a grid similar to the image below. The specific requirement is that item 2 should overlap item1, and all items except item1 should span the width of the container element. https://i.sstatic.net ...

Optimizing jQuery scripts by consolidating them to reduce file size

I've created a jQuery script that performs the same task but triggers on different events, including: Page load Dropdown selection change Clicking the swap button Typing in a text field However, I had to write separate scripts for each of these eve ...

What is the best method to replace the `click` event of an element selected using jQuery?

As I work on my program, I am attempting to alter the click event of a jQuery element. However, rather than modifying it as expected, it seems to be adding a new event each time. $myelem = $('.nav-item'); $myelem.click(function(){ console.lo ...

jQuery is being used to modify the HTML audio source, however, the previous file is still playing in both Firefox and

When I click a jQuery element, it changes the src attribute of an audio file. Despite confirming in the HTML console that the src is indeed being changed, Chrome and Safari (on OSX) do not update the audio file being played. Even after clicking the button ...

It encounters an error when attempting to fetch the 'src' attribute of a class

Is there a way to extract the HTML link found in the src attribute within a specific div on a webpage? The div structure is as follows: <iframe width="100%" class="idemo2" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="some/privat ...

Display the Ajax response in a designated div

I am facing an issue with my ajax code. It doesn't print any output, but when I use alert() to print the output, it shows up fine. $(".grp-ans").each(function(e){ $.ajax({ type: 'POST', url: 'show-answ ...

"Exploring the concept of undefined within object-oriented programming and its role in

Recently diving into Express and trying out routing by creating an object in a file to export. import userController from "../controllers/userController.js" // get all users router.get("/", isAuth, isAdmin, userController.list) Encoun ...

What are the correct steps for utilizing moment.js to modify the format of a timestamp?

Within my data.json file, I have a date stored in a long format. "start_time" : "1435377480000" To convert this long format into an actual date format, I am looking to utilize the power of moment.js. This is what I have attempted st ...