A div element retains its height even when empty, disregarding the minimum height set to

My goal is to style a div in such a way that its height adjusts based on the text it contains, as long as it stays within the maximum height set. However, I am facing an issue where even if there is no text inside the div, it still retains some height.

#container {
   width: 80%;
   margin-left: 10%;
   position: absolute;
   bottom: 0;
 }

 #input {
   width: 85%;
   float: left;
 }

 #submit {
   width: 15%;
   display: inline;
   float: right;
 }

 #display {
    display: inline-block;
    margin: 0;
    min-height: 0;
    max-height: 200px;
    width: 100%;
    overflow: scroll;
 }
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" >
<div class="form-group">
    <label for="usr">Terminal:</label><br>
    <input type="text" class="form-control" id="input">
    <button class="btn btn-primary" id="submit">Submit</button>
    <div id="display"></div>
  </div>

I attempted using height:0; max-height:200; but encountered the same issue where even with no text, the div retained some height rather than completely disappearing.

(For reference, I am using Bootstrap 4)

Answer №1

Ensure that the padding is set to 0 for the element with ID #display, and experiment with removing the overflow: auto property. Additionally, test out the usage of box-sizing: border-box

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

Utilizing jQuery to trigger animations when the form is hovered over or when the input box is

I am currently working on implementing opacity effects for an entire form when it is hovered over or when an input box is clicked while the mouse cursor has moved away from the hover area, ensuring that the effect remains visible. Here is the HTML code I ...

Resize the div based on the width and height of the window

My goal is to create a system or website that can be fully resizable using CSS and the VW (viewport width) unit. Within this system, I have integrated a GoogleChart that functions with pixels. Now, I am looking for a way to scale the chart using Javascript ...

problem with maximum width in Internet Explorer 8

Struggling with a compatibility issue in IE8. Here's my HTML code - Test in any browser and then try in IE8 jsfiddle.net/G2C33/ The desired output should be like this The problem is that the max-width property doesn't work in IE8. Note: Test ...

Learn the process of adding a tag to specific text with the help of JavaScript

I am attempting to implement a feature where the selected text will have a tag added to it. Within a textarea, I have some text entered. The goal is that when I select specific text from the textarea and click a code button, it should insert the tags aro ...

Determine if an object is empty in AngularJS

Is there a way to make a div element visible only after the user selects at least one checkbox? I attempted to achieve this using the following code within the div: <div class="col-md-1" ng-if="selectedElements.length > 0"> The variable selected ...

The rendering of Angular Material's <md-select> component appears to be faulty

I am currently working on integrating Angular material into a Feedback-Form project. My current challenge involves implementing the <md-select> element to allow users to select different titles (such as Mr., Mrs., etc.), but unfortunately, it is not ...

access denied on image links

While developing a web app with Angular5, I encountered an issue regarding retrieving image URLs from the 4chan API. Each post in my database contains an image URL, however, when I try to access it through my app, I receive a 403 forbidden error in the con ...

Saving information to a file using PHP

I am currently attempting to write text to a .txt file on my Mac when a button is clicked in the HTML. Here is what I have tried so far: HTML: <form style="margin-top:70px;" align=center action="write.php" method="post"> <input type=" ...

How can I make a div move to the position of another div and stay with it when the screen is resized?

In my card game project, I am dealing with an issue where cards are not aligning properly with the designated "dropZonePositions" when the screen is resized. Despite creating animations for the card movement that I'm satisfied with, the problem arises ...

Style the item with flexbox to have a border around it without increasing its height

In this scenario, the border is not surrounding the blue box but rather extends over the entire window height. Is there any advice on how to create a border around the blue box? Important Points: The HTML and body definitions cannot be altered. The pad ...

Ways to incorporate physics into CSS animations

Creating a loading screen with CSS and aiming for realistic behavior can be a challenge. Utilizing the animation-timing-function: cubic-bezier(1, 0, 1, 1) property gives a decent result, but perfecting it requires understanding how the parameters in cubic- ...

Using localStorage.getItem() to select SVG <g> elements

On my website, I have incorporated two <iframe> elements that link to separate HTML files containing SVG images. When a user clicks on an svg element in file1.html, an ID number is generated and stored using the code: localStorage.setItem("element1i ...

When attempting to modify styles in IE10, I consistently encounter an error message stating "Unable to evaluate expression."

Below is a JavaScript function I have created to hide an HTML tag: function hideObject(objectId) { var obj = document.getElementById(objectId); if (obj) { obj.style.display = "none"; } } I encountered a strange issue when using this ...

"Struggling with setting the default checked state for single and multiple checkboxes? The ng-init method with checkboxModel.value=true seems to be ineffective – any suggestions

<input type="checkbox" ng-model="isChecked.value" ng-true-value="'yes'" ng-false-value="'no'" ng-click='handleCheckboxChange(isChecked.value, idx);' ng-init="isChecked.value=true" /> ...

Which web browsers are compatible with the input attribute "multiple"?

I am currently incorporating this particular plugin, and its file input does not support multiple file selection. To address this issue, I have added the 'multiple' attribute. However, I am curious if there are any browsers or other platforms (su ...

The alignment of the image on a mobile device appears to be off

I've been trying to center an image on my website, and it looks perfect when viewed on a desktop computer. However, when I load the page on a mobile phone browser, it appears a bit off. This is the CSS code I'm using to center the image: #logo ...

Seeking recommendations for changing the background image of the body tag

My latest project involves a new website layout provided by our client. The design includes a 1280X1795px landscape image as the background, which the client is adamant about keeping. Now, my concern is how to best utilize this image as a background while ...

Make sure to use jQuery to fill in any missing HTML tags in dynamic content

Can someone assist me in identifying elements on my webpage that are not properly enclosed within HTML tags? For instance, consider the following situation: This is the picture of my village <img src="path_to_image" <br> some other text..... In ...

Understanding the Flex Layout: Decoding the Meaning of "flex-basis: 1e-09px"

In my experience with Angular Flex Layout, I've come across a situation where it applied flex: 0 1 1e-09px to an element. I'm curious about the significance of the 1e-09px value and whether it is a valid input for this property or if it was unin ...

Animating a div in CSS3 to expand horizontally from left to right without affecting its original position

I am currently in the process of developing a calendar using HTML, CSS, and JavaScript. The main purpose of this calendar is to showcase upcoming and past events. However, I am facing difficulties in ensuring that my event blocks occupy the remaining space ...