What is the best way to make a container 100% tall and display a navigation bar?

Struggling to properly render my React page

This is what I have:

ReactDOM.render(
    <React.StrictMode>
        <Provider store={store}>
            <Router />
        </Provider>
    </React.StrictMode>,
    document.getElementById('root'),
)

In my index.html file, I include the following:

html, body, #root, #root>div {
  height: 100%;
  overflow: hidden;
}

Within the router component:

            <>
                <GlobalStyle />
                <Nav/>
                <div>
                    <Router>
                        <Route component={Home} path="/" />
                    </Router>
                </div>
            </>

The goal is to display a nav bar at the top and have the components below fill up the remaining screen space without overflowing. However, every attempt ends in failure.

I've experimented with setting a fixed height for the nav bar (height: 100px !important), which works but causes other layout issues. A mysterious div called

<div tabindex="-1" style="outline: none">
seems to disrupt things when set to 100%, leading me to believe it's an accessibility feature. Making both that div and the container div below it to 100% solves the problem temporarily, but it's not a sustainable solution.

I expected the CSS code in the HTML file to cascade down, so it's puzzling why it isn't affecting this particular div. Could the navbar styling be interfering?

In the end, all I want is a full-screen page with a 100px navbar. Any thoughts on how to achieve this?

Answer №1

Utilize the power of flexbox for responsive designs.

Implement the following CSS properties accordingly:

For the main container =>

display: flex;
flex-direction: column;

For the navigation bar =>

height: 100px;

For sibling elements =>

flex-grow: 1;

Answer №2

It is recommended to implement the following CSS snippet:

html, body, #main, #main>section {
  min-height: 100vh;
  overflow: hidden;
}

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

Having trouble installing firebase using npm

Currently, I am utilizing React (if that's relevant). While researching on Google, the common solution I found was to clear the npm cache: npm cache clean --force However, this method didn't resolve the issue. I also went ahead and deleted the ...

Ways to incorporate error handling in node.js/express when using mySQL operations

I am currently focusing on enhancing the error handling capabilities in my node/express application, however, I find myself a bit confused. As an example, here is a route within my code that I wish to refine: app.get("/api/max-value", function (req, res) ...

What is the best way to wrap the content of a div and include ellipsis at the end?

There is a div on my page that shows some content. What I need is for it to display only the first 10 characters followed by '...' if the content exceeds that limit. 10 characters + '...' I have the option to use either jQuery or PHP ...

Deriving worth from a JSON object

My JSON data structure has the following format: .... "location" : { "lat" : 37.42140090, "lng" : -122.08537010 }, .... I am having trouble accessing the lat and lng values. Any suggestions on how to do this? Cu ...

What is causing the chat-widget to display a null value for the style read property?

Could someone assist me with hiding the Widget-chat? I keep getting an error that the property of style is null. Any help would be greatly appreciated. Thank you in advance. document.getElementById("chat-widget").style.display='none'; ...

Guide on implementing a ViroReact function in different components

Currently experimenting with viroReact to locate an image and then showcase some media content. My goal is to be able to transition to a custom react view after the anchor has been located, as displaying basic react elements in an AR scene with viro is no ...

Loop through and display content on the webpage with a for loop

I'm attempting to create a loop that will display information in three different areas of the DOM. Essentially, I have an array of enemies and I want to randomly select three of them to display in separate HTML div classes (firstEnemy, secondEnemy, th ...

Gain a comprehensive understanding of the JavaScript syntax utilized throughout the code

I stumbled upon this JavaScript code that enables asynchronous file uploads, but there are certain parts of it that I'm struggling to grasp. Any insights or explanations would be greatly appreciated - many thanks in advance. // Utilizing Ajax for Fil ...

Is there a way to develop a login form that retrieves information from a Google Sheet database?

Please help me with a solution. I have developed a registration form which effectively saves users' information in a Google Sheet. However, now I am yearning to create a login form that verifies the stored data and redirects the user to a different pa ...

ng-class not displaying the correct results

Within my form, I have a condition where if $isvalidate is true, the button receives the class 'disable-reg-btn'. Here is an example: ng-class="{{reg_form.$invalid ? 'disable-reg-btn' : ''}}" However, when I view the page in ...

Troubleshooting: Issues with jQuery animate() not functioning properly when adjusting CSS

Currently, I am experimenting with jQuery's .animate() function to change the background of a div when it is scrolled more than 100 pixels down a page. Previously, I had successfully used .css() for this purpose. JS: $(window).scroll(function () { ...

Select Menu (Code Languages:CSS, JS, HTML, BBCode)

I'm currently in the process of setting up a BB code for a forum I moderate. Here's the code snippet I'm using to generate a dropdown box that users can add to the signature field of their profiles: <!DOCTYPE html> <html> <d ...

Activate response upon verifying website link

I am adding functionality to my HTML page where I want certain sections to be visible when the user clicks on a link. Initially, these sections are hidden using the CSS property display: none;. My aim is to make these sections visible when the user clicks ...

What is the best approach for rendering HTML on a page both initially and dynamically as it is updated, given the heavy utilization of ajax?

One challenge faced by many web applications today is how to efficiently reuse html templates without redundancy when initially rendering a page and adding new content. What is the most effective approach for this? One option is to render the HTML page ...

Incrementing values in ng-repeat object automatically

My project involves extracting game information from mlb.com and utilizing angularjs along with the ng-repeat directive to display it. A sample of the JSON feed is shown below. { "data": { "games": { "next_day_date": "2017-08-19", "mo ...

Using JQuery to parse an XML file and automatically redirecting the page if a specific attribute equals "Update"

Updated I've made some edits to clarify my request. My website is built using HTML5, CSS3, and JQuery, resulting in all content being on one page. During updates, I want the ability to set an option in a configuration file so that when users visit m ...

What is the best way to showcase an array stored in the constructor's state using react-data-table-component?

I recently started working with React and I'm trying to use react-data-table-component to display data fetched from an API in a sorted table. However, I'm facing an issue as I don't know the correct method to utilize react-data-table-compone ...

I am attempting to access and display the properties of a higher-level component within a nested component

Trying to access the props passed to my parent component using this.state.props in my child component. Searching high and low on the internet for a solution. Choose(){ console.log(this.props.size); } {this.props.size && <DropdownIte ...

Displaying a component multiple times based on an array retrieved from an API

I am currently working on a side project to create a stock market app. I have utilized the useState hook in order to retrieve data from the finnhub API, resulting in an array of objects representing various stock market companies. const [finance, setFinanc ...

Dynamic HTML gallery that supports the addition of fresh images

Looking to showcase images from a local folder in a slideshow on a simple web page? The page should automatically update when new images are added or removed from the folder. I am not an expert and prefer a minimalist design with perhaps just a transitio ...