What might be preventing me from achieving a full-length page using height 100% or height 100vh?

I am currently working on a web application that has a similar layout to Slack. I am facing an issue where the page doesn't take up the full width and height as intended. The problem seems to be that it sometimes only occupies half of the screen while other times it extends further, but the left navigation bar does not have consistent dimensions. In particular, the top 60% of the left navigation appears with a different background color compared to the bottom 40%.

I have tried various solutions including setting 'height:100%' and 'height:100vh' for *, html, and body elements, but none seem to work as expected.

* {
  font-size: 16px;
  margin: 0;
  padding: 0;
}
.app {
  display: flex;
  flex-direction: row;
}
.leftNav {
  border-right: 1px solid black;
  width: 17%;
  padding: 0px;
  margin: 0;
  background-color: lightslategray;
  color: white;
}
.leftNav .title {
  font-weight: 500;
  padding-top: 10px;
  padding-left: 10px;
}
.main {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}
.main .messagesListContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.main .messagesList {
  padding: 5px;
}
.main .newMessage {
  width: 100%;
}
.messagesList {
  max-height: 450px;
  overflow: auto;
}
.messagesEntry {
  margin: 5px;
  border-bottom: 1px solid black;
}
<div class="app">
        <div class="leftNav">
          <div class="title"> Channels </div>
          <div>
            Channel 1
          </div>
          <div>
            Channel 2
          </div>
        </div>
        <div class="main">
          <div class="bar">
            <Navbar>
              Navbar goes here
            </Navbar>
          </div>
          <div class="messagesListContainer">
            <div class="messagesList">
              What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
            </div>

            <form>
              <div>
                <input placeholder='input' />
              </div>
            </form>
          </div>
        </div>
      </div>

Answer №1

Considering your goal of creating an app similar to Slack, I have made some adjustments. The top navbar and the bottom input will now be fixed in place.

Here are the changes I've implemented:

  • I added height: 100vh to the .app class, which acts as the wrapper for your application.
  • I included overflow: auto in the .main .messagesListContainer to allow for scrollability of the inner content.

These modifications should address the issue you were facing.

* {
  font-size: 16px;
  margin: 0;
  padding: 0;
}

.app {
  display: flex;
  flex-direction: row;
  height:100vh;
}

.leftNav {
  border-right: 1px solid black;
  width: 17%;
  padding: 0px;
  margin: 0;
  background-color: lightslategray;
  color: white;
}

.leftNav .title {
  font-weight: 500;
  padding-top: 10px;
  padding-left: 10px;
}

.main {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

.main .messagesListContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: auto;
}

.main .messagesList {
  padding: 5px;
}

.main .newMessage {
  width: 100%;
}

.messagesList {
  max-height: 450px;
  overflow: auto;
}

.messagesEntry {
  margin: 5px;
  border-bottom: 1px solid black;
}
<div class="app">
  <div class="leftNav">
    <div class="title"> Channels </div>
    <div>
      Channel 1
    </div>
    <div>
      Channel 2
    </div>
  </div>
  <div class="main">
    <div class="bar">
      <Navbar>
        Navbar goes here
      </Navbar>
    </div>
    <div class="messagesListContainer">
      <div class="messagesList">
        What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry...
       

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

Gradually alter the content within the div while transitioning the background color

I'm working with a div that has the following CSS properties: #results { background: #dddada; color: 000000; cursor: pointer; } #results:hover { background: #3d91b8; color: #ffffff; } How can I smoothly change just the text inside this div, u ...

Utilizing Data Binding in D3.js

Why is the text "Hello" not appearing five times on the page as expected? index.html <html> <head> <title>Data Binding</title> </head> <body> <h1>D3.js</h1> <script src="https://d3js.o ...

Has the user successfully authenticated with Google?

Possible Repetition: How to verify if a user is logged into their Google account using API? I'm working on a website that displays a Google Calendar. My query is: Can I determine whether a user is currently logged into a Google Account? If it&ap ...

JavaScript: Can you clarify the value of this variable using five sets of double quotations?

Could you please review the code snippet below for me? <script type="text/javascript"> function recentpostslist(json) { document.write('<ul class="recommended">'); var i; var j; for (i = 0; i < json.feed.entry.length; i++) { ...

Firefox Flaw: Animation Issues with CSS

My Website has a CSS animation that creates a hover effect on a button. While the animation looks good in Chrome and IE, I encountered an issue with Firefox. Some white pieces are still visible after hovering. Here is the Animation CSS: .Hotel:hover{ ...

Incorporating image URI into HTML for validation purposes

My website validation is encountering issues, mainly due to data/images base64 URIs. I ran a diagnosis on Error: Malformed byte sequence: e9. At line 2, column 259 (etc.) The analysis from https://validator.w3.org/ simply states that it cannot anal ...

Displaying MongoIds in HTML output for the user

Currently, I am in the process of developing a web application that utilizes MongoDB as its database management system. One challenge I am facing is finding a way to accurately identify which object the user has selected from a list on the screen, and the ...

Using SCSS to target a sibling class when hovering over an element with CSS

Is there a way to alter styles of a sibling element on hover using only CSS? I attempted something similar but was unsuccessful. HTML: <ul> <li class="item active">name1</li> <li class="item">name2</li> <li clas ...

Guide on adjusting the darkness of a MaterialUI Avatar component image and adding text to it

I'm currently working with the Avatar component from Material UI along with Tailwind CSS. I found that by simply adding the image URL to the src, it displays the avatar successfully. <Avatar alt="Cindy Baker" src="https://mui.com/sta ...

Images within inline blocks appear to be extending beyond their containing div as though they are

When I check my website in various browsers such as Firefox, IE, Edge, and Safari, I noticed that the images in the "My Specialties" section of the left column are extending outside of the div instead of fitting within it. This problem also occurs in Chrom ...

The values in my array are causing it to output NAN

I'm currently working on a program that aims to combine a variable number of one-row matrices with varying lengths. The goal is to add the elements of each matrix together, where element one of array one adds to element one of array two, and so forth. ...

Exploring Vue's data binding with both familiar and mysterious input values

How can I model an object in Vue that contains both known and unknown values? The quantity is unknown, but the type is known. I need to present user inputs for each type, where the user enters the quantity. How should I approach this? data() { retur ...

Creating visually appealing website designs with Firefox by implementing smooth background image transitions using Javascript with

Currently, I am facing an issue with the banner area on my website. The background of the banner is set to change every 10 seconds using JavaScript. However, there seems to be a flickering effect that occurs for a brief moment when the background-image is ...

Calling functions in AngularJS/HTML can help you execute specific

Just started with angularjs and facing some major issues haha... I have something that seems to be working fine, but I can't figure out what's wrong with this code... can someone please help me? Here it is: Basically, the scope.create function ...

Looping through two arrays of objects using Angular's NgFor directive

I need to iterate through two separate arrays using ngFor in order to display their content in an html format. <div class="form-check ml-5" *ngFor="let item of competencias.competencias; let i = index"> <input class=" ...

Is there a way to extract the number from a b tag using selenium with Python?

I'm attempting to extract the numbers within all the <b> tags on this particular website. I am looking for each "qid" (question id), so I believe I need to utilize qids = driver.find_elements_by_tag_name("b"). Following suggestions fro ...

Create a JavaScript button that redirects to a different page within a React application

I am creating a div element using a for-loop and I want to link each div to the "/campaign" page with its respective id. When a div is clicked, I want it to navigate to the "/campaign/id" page and pass the id to the Campaign component. class Home extends ...

Engaging 3D Object with JavaScript Interactivity

I'm currently working on a project for my HCI assignment where I need to create an interactive Sphere using JavaScript. However, I am new to JavaScript and Three.js. My goal is to have the sphere display statistics of a specific subject when clicked. ...

Resolve the issue with the sticky positioning

I'm dealing with a table and struggling to make the CSS sticky position work. Can someone help me troubleshoot? .table_wrapper { width: 100%; height: 400px; overflow: auto; position: relativ ...

Using Selenium with C# to input text into an HTML <input> tag is not functioning properly

I need help figuring out how to fill in an input field on a website using HTML. Here is what the section of the website () looks like: <div class="flex-item-fluid"> <input autocomplete="username" autocapitalize="off" ...