Utilizing CSS Positioning in a Slidebar

Currently, I am working with Tailwind and reactJS. I have two separate jsx files - Navpanel.jsx & Home.jsx.

The issue I am facing is that when I use a fixed position for the Home Text, it ends up overlapping with the navpanel. I have tried using block instead of flex, but then the Navpanel covers the entire screen. Can anyone provide a solution for this?

function Navpanel() {
  return (
    <div className="fixed flex h-full w-1/5 overflow-hidden from-gray-800 to-blue-800 before:h-full before:absolute before:w-screen before:bg-gradient-to-r before:content-[''] before:-z-10"></div>
  )
}
function Home() {
  return (
    <div className='flex relative'>Home</div>
  )
}

https://i.sstatic.net/HDeGg.png

Answer №1

Ensure that both the navigation and the navigation component are kept in the App.js file. You can structure your App.js file as follows:

const App = () => {
  return (
    <>
    <div className="max-h-screen w-full">
      <Navbar />
      <div className="flex items-center w-full" >
        <SidePanel />
        <HomePage />
      </div>  
    </div>
    </>
  )
}

export default App;

Within the home page component, you have the freedom to define anything you wish.

For inspiration, consider the example below:

<script src="https://cdn.tailwindcss.com"></script>
<div class="max-h-screen h-full w-full">
  <div class="flex items-center w-full ">
    <div class="w-1/3 h-screen bg-rose-500">Side Panel</div>
    <div class="w-2/3 h-screen bg-blue-500">Home Panel</div>
  </div>
</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

Adjust the vertical size of the slider in Jssor

Hi there! I'm currently working on a slider that I want to have a dynamic width (100% of the container) and a static height of 550px on PCs, while being responsive on mobile devices. Below is my code snippet: <div class="col-md-6 right-col" id="sl ...

Tips for simulating localStorage in TypeScript unit testing

Is there a method to simulate localStorage using Jest? Despite trying various solutions from this post, none have proven effective in TypeScript as I continue encountering: "ReferenceError: localStorage is not defined" I attempted creating my ...

Steps to modify the background color of an IconButton upon clicking in Material UI

After clicking on the IconButton, the background color changes to an oval shape. I now need to modify the background color when it is clicked. CSS The CSS code for the IconButton changes the background color upon hover. I require a similar effect for the ...

React.js component not updating after state change

In my eCommerce application, I want the quantity of items in the shopping cart to increase when the user clicks on the plus icon. However, when the user interacts with the item, the state changes but the component does not re-render, causing the quantity n ...

Issue with activating the Menu Item when using NavLink in Semantic-UI-React

Currently, I am utilizing { BrowserRouter } along with this code snippet for my navigation bar. <Menu stackable> <Menu.Item as={NavLink} exact to='/' content='Home' /> <Menu.Item as={NavLink} exact to='/abc&apos ...

What are the best practices for utilizing ReactJS state within a component class?

I have created a sidebar component in React and have already prepared the CSS (the .sidebar.active class is used when the sidebar is shown): export default function Sidebar() { return ( <div className="sidebar">This is a sidebar< ...

Javascript and CSS combo for creating a stylish fade effect

Hey everyone, I have a design challenge where I need to change the color of a picture inside a box when the user hovers over it. I have four boxes like this and my goal is to make everything else fade out when a user hovers over a specific box. Anyone kn ...

The GraphQl Code Generator fails to correctly generate the graphql() function in Next.js applications

While working on my next.js project, I integrated GraphQL to generate types for queries. However, the code generator is not functioning properly and displaying an error message: "The query argument is unknown! Please regenerate the types." within the gql.t ...

What is the method to retrieve text from a div element with Webdriver-IO?

Is there a way to extract the value from the following HTML element using Webdriver-IO for automated testing? <div class="metric-value ng-binding" ng-style="{'font-size': vis.params.fontSize+'pt'}" style="font-size: 60 ...

Handling onMouseLeave event for Popover component in material ui library with hiderBackdrop parameter specified

<Popover key={element.id} className={classes.popoverItem} classes={{ paper: classes.paperElement }} open={isOpen} anchorEl={this.myRef.current} anchorOrigin={{ vertical: 'bottom&apo ...

Select DOM Elements Using JavaScript CSS Queries

As I delved into JavaScript in an attempt to craft my personal slider, I stumbled upon a perplexing discovery. I encountered a CSS regulation that looked like this: html.js #slideshow .slides img { position: absolute; } The explanation suggested that ...

Inconsistent Accuracy of React Countdown Timer

Hello everyone! I'm new to programming and I'm currently working on creating a countdown timer that goes from 3 to 0. The issue I'm facing is that the timer counts down too quickly when rendered on the screen. I've tried adjusting the i ...

Highlight the words in the text that correspond with the options provided

My task involves working with an array of words such as const = ['cat','dog']. I also have a text area, input field, or editable div where I need to input words and highlight any matches from the array. Currently, I am using the highlig ...

Adjust the styling of the minimized file input to work like a download button when the window is resized

I successfully minimized the fileInput function by removing the upload area and loading bar, giving it a similar appearance to a downloadButton. However, I'm facing difficulties in determining which part of the CSS code needs to be modified to make it ...

CSS: Handling Background Images Responsively

I'm experiencing an unusual issue where the image is not appearing, even though the div box shows up when I highlight elements on the page. Validation and inspection also show no issues. Here is the code: <div class="mainImage"></div> A ...

How to automatically reset a form after submission in React using Ant Design?

When using the antd template for form design, I encountered an issue where form input values were not getting cleared after submission. I attempted to use this.props.form.resetFields(), but it resulted in the following error: Unhandled Rejection (TypeErro ...

What is the reason behind the ineffectiveness of Rendering the List in a Separate Component when using the `Select` Component from material UI?

I have created two components. One component is responsible for rendering a list, which is then used within its parent component that hosts the Select component provided by Material UI. Below are snippets of both components: import React from 'react&a ...

There was an error in Index.js: The UserForm component did not return anything from the render function. This typically occurs when a return statement is missing. To render nothing, you can return

Hello, I'm a beginner with React and I'm attempting to add a row in my React app when a button is clicked. I referenced this guide on how to dynamically add and remove table rows in React.js However, I'm having trouble adapting it to my cod ...

How can I ensure that an item stays in place within a vertically sortable list using Dndkit? (I am also considering alternative drag-and-drop libraries)

Let's say for instance that 5 was marked as frozen. If 4 was then moved below 6, the change in arrangement would be as follows: before: https://i.sstatic.net/iVZFtAmj.png after: https://i.sstatic.net/tCq09Qgy.png My current approach involves us ...

The Art of Cascading Style Sheets Scrolling Alignment

Hello seasoned developers, I'm diving into the world of web design. I have a question about the code below. The yellow container scrolls under the nav bar as expected, but the red container scrolls above it. Can anyone provide some guidance? view ima ...