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

Flashing text compatibility across all browsers

I'm looking for a way to create text that blinks on all major web browsers. Initially, I attempted using the <blink> HTML tag, but unfortunately, it only works in Mozilla Firefox. Next, I experimented with CSS: <style> .blink {text-deco ...

Is there a way to conceal a component using Twitter Bootstrap while having the ability to reveal it with the help of

Suppose I generate an HTML element in the following manner, <div id="unique-div" class="concealed">Hello, TB3</div> <div id="unique-div" class="hide-me">Greetings, TB4</div> <div id="u ...

The behavior of table elements is distinct when using align="center" compared to utilizing CSS text-align: center

In my table setup, I have a parent table with a width of 100% and a child table with a width of 300px. I attempted to center the child table using CSS by setting text-align: center; (https://jsfiddle.net/wrzo7LLb/1/) <table class="body"> <tr> ...

Challenges with incorporating numerous text boxes in real time

There are two text boxes side by side with a "+" sign next to each. When the plus sign is clicked, a new text box appears with both the "+" and "-" signs for adding and removing the text box. I followed instructions from this resource to create my text box ...

Error: Unable to access property 'count.' because it is undefined

componentDidMount(props) { this.interval = setInterval(() => { if (props.count !== 0) { this.stateHandler() } }, 1000) } Encountering an issue with the interval, as the console is displaying the following error: Type ...

Getting the checkbox count value in a treeview upon successful completion of an AJAX request

After successful JSON Ajax response, a treeview structure with checkboxes is displayed. I need to capture the number of checkboxes checked when the save button is clicked. @model MedeilMVC_CLOUD.Models.UserView <script type="text/javascript"> ...

"Creating visual art with processing in 2D using P5

Recently, I came across a webpage about rendering 2D objects in processing using JavaScript. Here is the link to the page: Upon trying out the example code provided on the page in a new P5 project, I noticed that the code structure looked like this: HTML ...

What is the best way to create a personalized image as the background in WordPress using CSS for a client?

I have this in my style.css .showcase{ background: url("x.jpg") no-repeat 0; } My website is built on WordPress and I have implemented advanced custom fields for the client to edit text. However, I am struggling to find a way for them to change the ...

Issue with Internet Explorer's CSS

It appears that this page is not displaying correctly in Internet Explorer 9, along with possibly older versions as well. The issue seems to be with the right menu floating to the bottom of the page. Firefox, Chrome, and Safari are all rendering it correct ...

Extract the content of an element and incorporate it into a script (AddThis)

HTML: <div id="file-section"> <div class="middle"> <p class="description"> Lorem ipsum... </p> </div> </div> jQuery: var share_on_addthis = { description: $('#file-section ...

The periodLookup array does not have a defined value for periodStr. Why is this error being caught?

Here is a method that I am working with: set_period_help_text: function(periodInput){ var metric = MonitorMetric.getSelectedMetric(); var periodStr = $('select[name=metric_period]').val(); var datapoints = Number(periodIn ...

What's causing my struggle to override the bootstrap nav-link class in next.js?

I am facing an issue where I need to customize the active state of bootstrap .nav-link in the code snippet below: <li className="nav-item"> <a className={`${styles.navLink} nav-link`} role="tab" data-to ...

How to align content within a FormControlLabel using Material UI

My goal is to line up the label and radio button inside a FormControlLabel component so that the label occupies the same width regardless of its content. The current appearance can be seen below: https://i.stack.imgur.com/GhXed.png Below is the code I am ...

Polymer elements fail to adapt to varying screen sizes

I am currently working on creating a responsive website using polymer, but I have encountered an issue where certain elements (such as core-toolbar and paper-fab) are not scaling properly on smaller, denser screens like smartphones. After browsing through ...

display the hidden box contents when clicking the button within a PHP loop

I am attempting to create a simple e-commerce site for learning purposes, but I encountered an issue when trying to display information upon clicking a button. The button does not seem to trigger any action as expected. It is meant to reveal text from the ...

How can I adjust the size and alignment of each line within a single cell in an HTML table?

<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> <style> .chess-board { border-spacing: 0; border-collapse: collapse; } .chess-board ...

I clicked on the Bootstrap Navbar button but unfortunately nothing occurred

I'm encountering an issue with my navbar. When the screen size is reduced, a button appears, but clicking it does not trigger any action. Here's my code; however, I'm unsure why the button in the Navbar isn't functioning as intended. ...

"Encountering a Challenge: Cannot Assign Array to ngFor Directive in Ionic App, Displaying

I have encountered an issue while fetching product categories using API. The problem lies in the fact that the categories are being retrieved as an object instead of an Array which is required for *ngFor to work in Ionic. Any assistance on how to define th ...

Proper method for positioning text in a line

Trying to recreate the image below, but facing alignment issues with the text in my code. How can I vertically align the text so that they are aligned like in the photo? Flexbox hasn't helped due to varying text lengths causing misalignment. const ...

It is important for the CSS :active state to transition to an "inactive" state after a certain period of

For mobile, I utilized the :hover and :active pseudo-classes to create a transition effect when tapping on a tab that enlarges the elements for more information. However, I am seeking a way for the activated element to return to its original state after a ...