The height of the div does not adjust accordingly after the element is revealed

I have a page that is powered by angularjs and performs a specific function.
This function populates a hidden div, which is then displayed to the user.

The issue I'm facing is that when this text is shown, the main div containing my page content doesn't seem to resize properly. As a result, while the footer moves down correctly, it leaves a large amount of unsightly whitespace below, as shown in the images:

Before Function:
https://i.sstatic.net/9m7tc.png

After Function:https://i.sstatic.net/5fguV.png

How can I ensure that the main page content div resizes to fit this new content?

CSS:

* {
  margin: 0;
}

#body{
    background-color: #EAFFE5;
    margin: 0px;
    padding: 0px; 
    font-family: Calibri;  
}

.content{    
    width:85%;
    border: 0px solid #000;
    margin: 0px auto 0px auto;
    clear: both;
    text-align: center;
    min-height: 700px;   

}

.content a:link,
.content a:visited{
    color:blue;
}

.display{
    width: 90%;
    border: 0px solid #000;
    margin: 0px auto 0px auto;
    clear:both;
    text-align: justify;    
}

HTML:

<div id="body" ng-controller="recipeSubmitController">
        <div class="content">
            <title>Submit a recipe</title>
            <h3>Recipe Submission</h3>
            <div class='display'>
                <form name="recipeSubmitForm">
                    <p>Recipe Title: *</p>
                    <input type ='text' maxlength="200" id="titleInput" class="forminput" ng-model="titleInput"style="float:left;" placeholder="Paste or write recipe title here." required>

                    <br>
                    <br>

                    <p>Ingredients: *</p>
                    <textarea rows="5" maxlength="3600" class='formtextarea' ng-model="ingredientsInput" placeholder="Paste or write recipe ingredients here." required></textarea>
                    <br>
                    <br>

                    <p>Instructions: *</p>
                    <textarea rows="5" maxlength="3600" class='formtextarea' ng-model="instructionsInput" placeholder="Paste or write recipe instructions here." required></textarea>
                    <br>
                    <br>

                    <button id="basicRecipeSubmitButton" class="buttonstyled" style="float:right;" ng-click='basicRecipeSubmitClicked()'>Submit data</button>
                    <br>
                    <br>
                </form>

                <br>
                <br>                
                <div id="recipeMainBody" ng-show="parsedDataShown" ng-cloak="true">
                    <h4>Here's a sneak peek of how the recipe will look:</h4>
                    <br>
                    <h4><span  ng-bind="recipeObject.title"></span></h4>
                    <div id="recipeSideInfo" style="float:left; width:20%; text-align: left;">
                        <h4>Ingredients:</h4>
                        <li ng-repeat="ingredients in recipeObject.ingredients | orderBy:'-Amount'">
                            {{ ingredients.Amount + ' ' + ingredients.Units + ' '+ ingredients.Name}}
                        </li>

                    </div>
                    <div id="recipeInstructions" style="float:right; width:75%">
                        <h4>Instructions:</h4>
                        <li ng-repeat="instruction in recipeObject.instructions | orderBy: 'Step'" style="list-style-type: none;">
                            {{ instruction.Step + '. ' + instruction.Text }}
                        </li>
                    </div>
                </div>
            </div>


        </div>

Answer №1

#recipeInstructions is set to float, requiring the parent element to be cleared.

You have the option to create a .clearfix class and apply it to parents with floated children, or simply include this .clearfix CSS in #recipeMainBody.

* {
  margin: 0;
}

#body{
    background-color: #EAFFE5;
    margin: 0px;
    padding: 0px; 
    font-family: Calibri;  
}

.content{    
    width:85%;
    border: 0px solid #000;
    margin: 0px auto 0px auto;
    clear: both;
    text-align: center;
    min-height: 700px;   

}

.content a:link,
.content a:visited{
    color:blue;
}

.display{
    width: 90%;
    border: 0px solid #000;
    margin: 0px auto 0px auto;
    clear:both;
    text-align: justify;    
}

.clearfix:after {
    display: table;
    content: '';
    clear: both;
}
<div id="body" ng-controller="recipeSubmitController">
  <div class="content">
    <title>Submit a recipe</title>
    <h3>Recipe Submission</h3>
    <div class='display'>
      <form name="recipeSubmitForm">
        <p>Recipe Title: *</p>
        <input type='text' maxlength="200" id="titleInput" class="forminput" ng-model="titleInput" style="float:left;" placeholder="Paste or write recipe title here." required>

        <br>
        <br>

        <p>Ingredients: *</p>
        <textarea rows="5" maxlength="3600" class='formtextarea' ng-model="ingredientsInput" placeholder="Paste or write recipe ingredients here." required></textarea>
        <br>
        <br>

        <p>Instructions: *</p>
        <textarea rows="5" maxlength="3600" class='formtextarea' ng-model="instructionsInput" placeholder="Paste or write recipe instructions here." required></textarea>
        <br>
        <br>

        <button id="basicRecipeSubmitButton" class="buttonstyled" style="float:right;" ng-click='basicRecipeSubmitClicked()'>Submit data</button>
        <br>
        <br>
      </form>

      <br>
      <br>
      <div id="recipeMainBody" class="clearfix" ng-show="parsedDataShown" ng-cloak="true">
        <h4>Here's a sneak peek of how the recipe will look:</h4>
        <br>
        <h4><span  ng-bind="recipeObject.title"></span></h4>
        <div id="recipeSideInfo" style="float:left; width:20%; text-align: left;">
          <h4>Ingredients:</h4>
          <li ng-repeat="ingredients in recipeObject.ingredients | orderBy:'-Amount'">
            {{ ingredients.Amount + ' ' + ingredients.Units + ' '+ ingredients.Name}}
          </li>

        </div>
        <div id="recipeInstructions" style="float:right; width:75%">
          <h4>Instructions:</h4>
          <li ng-repeat="instruction in recipeObject.instructions | orderBy: 'Step'" style="list-style-type: none;">
            {{ instruction.Step + '. ' + instruction.Text }}
          </li>
          
          (Additional repeated instructions for brevity)

        </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

What is the reason behind BehatMinkElementNodeElement:setValue function removing dashes in the input value?

I am currently utilizing Behat version 3.0.15, Selenium version 3.4, and PhantomJS as the browser. In my Behat custom step, I have code to set the value of an input date field with a single line: $element->setValue('1999-01-01'); However, u ...

Deactivate the button until a selection is made in the ui-select component

Below is the code I am using to create a ui-select: <ui-select ng-model="newTask.work" theme="select2" class="form-control" title="Scegli un lavoro"> <ui-select-match placeholder="Scegli un lavoro">{{$select.selected.label}}</ui-select- ...

The spacing problem arises from the interaction between two HTML tags containing a Bootstrap file

view image details hereUsing Bootstrap 5, I have a screenshot with an h5 element in a black border and an em tag in a red border. I specified margin 0 to the h5 element but it still does not touch the em tag (in red border). I have tried adjusting line spa ...

"Enhancing HTML tables with jQuery for a polished look

This table belongs to me: <tr class=items> <td id=id_1></td> <td id=city_id_1></td> <td id=temp_1></td> <td id=date_1></td> </tr> ...

User IDs should not be shown on the jQuery datatable, although they are still accessible

I am wondering if there is a way to display certain user data in a datatable without showing the user id in the table itself. Here is my table: <table id="mitabla" class="display"> <thead> <tr><th>Last Name</th> ...

Angular dynamic calculations for min and max values result in an unusual user interface

I am encountering an issue with a datetime-local input field that has max and min attributes. <input type="datetime-local" ng-model="model.date" min="{{min}}" max="{{max}}"> These attributes are dynamically set based on the date from another input ...

Utilizing nested components with distinct styling techniques

I have a react component that accepts the size prop as either small, regular, or large. Depending on the size, a specific CSS class is assigned to style the component accordingly. Here's an example of how these classes are defined: .my-component { ...

Locating a button using XPath on Selenium

I have been struggling to find the specific button using Selenium WebDriver: <div class="_1gw6tte"> <div aria-hidden="false"> <div class="_159vfsnv" style="background-color: transparent;"& ...

Efficiently accessing and displaying nested models in AngularJS

Currently, I am in the process of developing a website that involves numerous relational links between data. For instance, users have the ability to create bookings, which will include a booker and a bookee, as well as an array of messages that can be asso ...

Implementing Javascript to allow users to interact with a dynamic table

All user entries are captured and stored in an array. The array output should be displayed in a dynamic table which includes edit and delete options. If the number of entries exceeds 3, then the table should also have previous and next navigation options. ...

The request response was a JSON object that started with the keyword "POST"

My frustration is growing as I encounter a strange issue with the stack template I purchased from envato market. Every time I attempt a simple ajax request, the json returned from my PHP script seems to be invalid. Interestingly, the exact same code works ...

IE11 fails to adhere to specified sizes in CSS Grid layout

I've been trying to replicate the display:grid and grid-template-columns functionality on IE11, but I can't seem to get it to work properly like it does in Chrome. What am I missing? Also, when I pasted my code into the snippet, the yellow bar do ...

Turn off Affix feature for mobile phones

Hello, I created a sidebar and used some JavaScript to automatically update its width in relation to its parent container. Now, I want the sidebar to be removed automatically when the window size goes below 750px (which I believe is the tablet breakpoint i ...

Displaying an image on canvas while showing a loading progress bar

I'm attempting to utilize this function to load an image into my canvas: function handleImage(e) { var reader = new FileReader(); reader.onload = function (event) { var img = new Image(); // img.onprogress = function (e) { ...

"Triggering CSS changes with the click of a

I am developing a basic calendar application in PHP and I would like to dynamically change the style of the <td> block based on user interactions. Specifically, I want to implement a behavior where once the "menuclick" class is active, the other cl ...

Feeling a bit lost on my first JQuery project, could use some

Yesterday, a kind person on this platform assisted me greatly in building my first validation from scratch. I have made significant progress since then. This is my first time working with JQuery, so I apologize in advance for my messy code. Everything work ...

Implementing a horizontal scrollbar for an AJAX datatable

Is there a way to incorporate a horizontal scrollbar into an Ajax Datatable? I attempted to use "ScrollX" :true, however, this method did not prove successful. $(document).ready(function () { $('#myDataTable1').DataTable({ "aj ...

What is the comparable javascript code for the <script src="something1.json"></script> tag?

Within my HTML code, I currently have the following line to read a JSON file: <script src="something1.json"></script> Inside this JSON file, there is a structure like so: var varName = { .... } This method of definition naturally sets up ...

JavaScript multi-layered structures

I am in need of assistance creating JavaScript objects and arrays to meet the following requirements. Can anyone provide me with a sample? Requirements Begin with invoice numbers. Key: invoice, Value: INV001, INV002, INV003... Each invoice number contai ...

Issues with the alignment of card-footer in Bootstrap 5 card components

Looking to enhance the website for the electronics store I am employed at, I have encountered a challenge while constructing cards using Bootstrap 5. Initially, the cards varied in height until I managed to resolve the issue by setting the card height to 1 ...