The div's height is not matching the CSS declaration as expected

In my HTML, I have a div called innerDetails which serves as a flex item with the following CSS properties:

.cover {
                    height: 100vh;
                    width: 100%;
                }

                #screenContainer {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                }

                /* Other CSS styles omitted for brevity */
             
            

I am facing an issue where the height of the div reduces automatically from the specified 100% to 0%. Adding padding did not resolve this issue. However, when I add text inside the div, only that portion displays the background image.

https://i.sstatic.net/3Z6tp.png

Answer №1

Simply delete the height: 100% from the .innerDetails class

.cover {
  height: 100vh;
  width: 100%;
}

#screenContainer {
  display: flex;
  justify-content: center;
  align-items: center;
}

#screen {
  height: 90vh;
  width: 87vw;
  background-color: #eeeeee;
  border-radius: 2%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

#innerScreen {
  background-color: #060b22;
  height: 80vh;
  width: 80vw;
  padding: 15px;
}

#details {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap-reverse;
}

.innerDetails {
  /* height: 100%; */
  width: 45%;
  font-size: 1.7vw;
  color: rgb(255, 117, 67);
  font-family: Arial, Helvetica, sans-serif;
  text-align: justify;
}

#backImage {
  background-image: url(https://placehold.it/250px250);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}
<div class="cover" id="screenContainer">
  <div id="screen">
    <div id="innerScreen">
      <p class="heading" id="arr"></p>
      <div id="details">
        <div class="innerDetails">
          <p id="p1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tincidunt ligula vel urna blandit, ut auctor dolor fermentum. Aenean ut augue tincidunt, bibendum nunc non, pulvinar nisl. Maecenas dapibus, ante vel tincidunt laoreet, sem ex finibus
            odio, sit amet ultricies ligula nunc a sem. Nam nulla velit, congue sit amet commodo interdum, consectetur sed nisi. Vivamus commodo dictum augue nec consectetur. Curabitur molestie viverra interdum. Nullam vel augue sed sem vulputate vulputate
            non id sapien. Aenean posuere egestas orci. Duis vitae suscipit ante, tempor tempor risus. Sed ut augue quis elit blandit maximus. Phasellus sit amet arcu et odio tristique malesuada</p>
        </div>
        <div id="backImage" class="innerDetails">fdbd</div>
      </div>
    </div>
  </div>
</div>

The current setup is functioning fine, but the #details section lacks specified height. To address this, include height: 100% to the #details segment and observe the changes.

.cover {
  height: 100vh;
  width: 100%;
}

#screenContainer {
  display: flex;
  justify-content: center;
  align-items: center;
}

#screen {
  height: 90vh;
  width: 87vw;
  background-color: #eeeeee;
  border-radius: 2%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

#innerScreen {
  background-color: #060b22;
  height: 80vh;
  width: 80vw;
  padding: 15px;
}

#details {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap-reverse;
  height: 100%; /* or 300px etc */
}

.innerDetails {
  height: 100%;
  width: 45%;
  font-size: 1.7vw;
  color: rgb(255, 117, 67);
  font-family: Arial, Helvetica, sans-serif;
  text-align: justify;
}

#backImage {
  background-image: url(https://placehold.it/250px250);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}
<div class="cover" id="screenContainer">
  <div id="screen">
    <div id="innerScreen">
      <p class="heading" id="arr"></p>
      <div id="details">
        <div class="innerDetails">
          <p id="p1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tincidunt ligula vel urna blandit, ut auctor dolor fermentum. Aenean ut augue tincidunt, bibendum nunc non, pulvinar nisl. Maecenas dapibus, ante vel tincidunt laoreet, sem ex finibus
            odio, sit amet ultricies ligula nunc a sem. Nam nulla velit, congue sit amet commodo interdum, consectetur sed nisi. Vivamus commodo dictum augue nec consectetur. Curabitur molestie viverra interdum. Nullam vel augue sed sem vulputate vulputate
            non id sapien. Aenean posuere egestas orci. Duis vitae suscipit ante, tempor tempor risus. Sed ut augue quis elit blandit maximus. Phasellus sit amet arcu et odio tristique malesuada</p>
        </div>
        <div id="backImage" class="innerDetails">fdbd</div>
      </div>
    </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

My Jquery "animate" is only triggered once instead of on each function call. What could be causing this issue?

I have set my navigation to dock at a specific document height on the top of the viewport, and when it docks, it should display a dropdown animation. $(document).scroll(function(){ var x = $(window).scrollTop(); if(x>=700){ $("header ...

Enhance container and typography for layouts converted to 1920px width to improve overall design

Greetings to all! I need some assistance with converting a design file that is 1920px wide into an HTML layout. Can someone provide tips on optimizing containers and typography for responsiveness? Specifically, I would like the font-size and line-height ...

Using jQuery to smoothly scroll horizontally to a specific div element

In my project, I aspire to create a layout similar to the BBC website: with a side scroll from section to section. Here is my code and the issue I am encountering: jsFiddle: http://jsfiddle.net/neal_fletcher/kzQFQ/2/ HTML: <div class="wrapper"> ...

jquery hover effect not functioning properly

I have a question regarding my jquery mobile application. I am trying to implement a hover effect on items with the class grid-item, where the width and height change simultaneously in an animation. Here is the code snippet I am using: $('.grid-i ...

Display column header row divider for pinned columns in v5 DataGrid

I'm attempting to customize the appearance of pinned columns in MUI's DataGrid by adding a column header-row divider. The official demo by MUI for pinned columns [https://codesandbox.io/s/qix39o?file=/demo.tsx] displays the pinned column header ...

Unexpected behavior from Internet Explorer - Span contents remain unchanged despite valid input

I have a simple question because I'm feeling a bit lost. Check out this JSFiddle link It seems that in Internet Explorer, the contents of my span won't update even though the input is valid. However, in other browsers, the span content changes ...

What is the best way to get my loading screen div to cover the entirety of my screen, including all content beneath it?

In order to create a loading screen, I am utilizing PHP to dynamically load specific services for my website. I attempted to set the height of my wrapper div to 100% but it did not produce the desired results. After that, I experimented with setting the he ...

Arranging items in a flex container

My goal is to achieve the following layout with flexbox: #box { display: flex; flex-wrap: wrap; flex-direction: row; justify-content: center; justify-items: center; align-items: center; } #spotLight img { width: 15%; height: 15%; } # ...

How can I add color to arrow icons in tabulator group rows?

Is there a way to specify the color of the arrows in collapsed/expanded group rows? Also, what CSS code should I use to define the font color for column group summaries? You can view an example of what I am trying to customize here: https://jsfiddle.net/s ...

What is the best method for aligning forms vertically within a page layout?

I'm working on designing a contact form, but I'm having trouble getting everything to align properly. Specifically, I can't seem to get the form elements to line up vertically and I also want the Message label to appear on the top left side ...

There are times when JQuery scripts fail to function correctly

Hello there. I'm having an issue with my website - www.robbiedawson.com. Sometimes, the text in the grey footer fails to load properly, including numbers and links, making navigation impossible. This happens occasionally when refreshing the page, whet ...

Is there a way for me to insert a variable into the src attribute of my img tag like this: `<img alt="Avatar" src=`https://graph.facebook.com/${snAvatarSnuid}/picture`>`

I need assistance with passing a variable called snAvatarSnuid within the img src tag, specifically after facebook.com/ and before /picture as shown below: <img alt="Avatar" src=`https://graph.facebook.com/${snAvatarSnuid}/picture`> Note: 1) The ht ...

Attempting to create a child process within the renderer by triggering it with a button click

I'm currently developing an electron application where I am attempting to initiate a child node process (specifically to run a Discord.JS bot). Below is the code snippet in question: index.html: <tr> <th class="title-bar-cell" ...

Tips for implementing and utilizing onclick functions in EJS

My goal is to develop a trivia game with interactive features. I aim to enable users to click on an answer, which will trigger a border effect and increase the points variable. Below is the layout of the entire page: <% include ../partials/boilerp ...

In what rare scenarios does JS in string concatenation within insertAdjacentHTML fail to evaluate?

On a public website that I do not own, there is a piece of JavaScript code that writes a magic pixel image to the page to call an API I provided. Here's the snippet of code: n.insertAdjacentHTML('beforebegin', '<img src=& ...

audio enhancement in a web-based game

I'm having trouble getting a sound effect to play consistently in my game whenever there is a hit. Sometimes the sound plays, other times it does not! Here is the code I am using: <script> var hitSound = new Audio(); function playEffectSound ...

Utilizing the modulo operation for organizing rows and columns

I’ve seen this question asked many times, but I’m still struggling to figure it out. The examples I’ve come across are either too complex or involve Angular or Javascript. My goal is to learn how to set up 4 columns within a row. // initiating a ...

Implement a vertical scrolling animation in datatables

I am trying to utilize datatables to display all data. My goal is to have the data automatically scroll row by row every 3 seconds. This is my code, and you can also check it out on jsfiddle The intention is to showcase this data on a large screen. < ...

Display a button within a table depending on the content of adjacent cells

Below is the code snippet I'm currently working with: <tbody *ngIf="packages"> <tr *ngFor="let package of packages"> <td class='checkbox'> <label class="css-control css-co ...

Tips for avoiding duplicates when searching with the simple HTML DOM parser

Is there a way to exclude duplicate content from an HTML page using the simple HTML dom class? For example, if you check out this link: http://www.gutenberg.org/wiki/Category:Agriculture_Bookshelf, you'll notice that the term Forestry appears twice. ...