Troubleshooting the min-height problem with CSS in AngularJS Routing

My current setup is as follows in a basic HTML file:

* {
  box-sizing: border-box;
}

html, body {

  height: 100%;
  min-height: 100%;
  margin: 0;
}

section {
  display: block;
  width: 100%;
  min-height: 100%;
  padding: 1em
}

.b1 {
  background: #2AC56D
}
.b2 {
  background: #fae10c
}
.b3 {
  background: #03a9f4
}
<section class="b1">1
</section>
<section class="b2">2
</section>
<section class="b3">3
</section>

Next, I attempt to incorporate AngularJS Routing by placing the section elements within a template named template.html like this:

<section class="b1">1
</section>
<section class="b2">2
</section>
<section class="b3">3
</section>

I then include AngularJS, the ng-route dependencies, and the following script in the main file like so:

<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>
<script>
var app = angular.module('app', ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
    $routeProvider.when('/', {
        templateUrl: 'template.html'
    }).otherwise({
        redirectTo: '/'
    });
});
</script>
</head>
<body data-ng-app="app">
    <div data-ng-view>
    </div>
</body>

The scripting part functions correctly, but now the section elements no longer stretch to full height and appear like this.

I am facing an issue with this layout, and I need assistance on how to resolve it. My goal is to have certain div's or section's at least full screen height.

Thank you.

Answer №1

Ensuring that the height: 100%; property works correctly requires setting it in the parent div as well.

Consider the following HTML structure:

<div id="container">
  <section>Content here</section>
</div>

Solely applying a 100% height to the section element will not suffice. It is essential to establish a fixed height for the parent element. Thus, use the following CSS:

#container{
  height: 100%;
}

You have already set the height to 100% for the html and body tags, which is beneficial.


In your specific scenario, implement the following CSS:

div[data-ng-view]{
   height: 100%;
}

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 methods does Grunt use to determine file paths?

Currently, I've been examining a demo Angular application. Upon inspecting the index.html file, I noticed this line: <script type="text/javascript" src="/static/<%= grunt.config.get('pkg.name') %>.js"></script> My unders ...

"Add a touch of magic to your webpage with text effects that appear

I am looking to create a glowing text effect, and I stumbled upon this resource. http://jsfiddle.net/karim79/G3J6V/1/ However, the client prefers the text effect to appear after the page loads, rather than on hover. Unfortunately, I do not have experien ...

Efficient ways to enhance CSS animations (including scaling, rotating, and blurring)

In this HTML example, there are two animated pictures - one background and the other an object. Despite using scale and rotate animations, the performance is choppy on full HD monitors, especially in Firefox where it runs at about 20 fps. Initially, jQuer ...

Only the box that I click on will receive the applied color

I am facing an issue with applying colors to the label colorCheckBox, each with a unique data-id that is derived from the variable colorBoxId, which is globally accessible using colorBoxId = $(this).closest('tr').data('id');. The proble ...

Angular2 poses a strange problem with ngClass

It seems like Angular is expecting me to use single quotes for the class names even if there are no hyphens in my CSS class name. I've tried everything but Angular keeps insisting on using hyphens for this specific CSS class... it's strange, or m ...

Struggling to effectively align the footer div in a responsive design

Check out this GitHub link to access the HTML file and CSS: https://github.com/xenophenes/pgopen-splash2016 I'm facing an issue with the footer text alignment. Despite my efforts, I can't seem to center it properly as it keeps appearing slightly ...

Guide on inserting a dropdown menu following a specific count of <li> elements using Javascript or Jquery

I am currently working on an HTML project <div class="ktmsg"> <ul> <li class="a1"> <a title="Link Tools" href="#"> … </a> </li> <li class="a2"> <a title="Link Tools" href="#"> ...

Centering a form on a webpage with Bootstrap: A step-by-step guide

Utilizing twitter-bootstrap for styling, I have implemented a login form and am attempting to center it on the page. Most suggestions on stackoverflow advise placing elements inside the container class, which is what I have done. The requirement is for t ...

Guide on sending a model to a Bootstrap modal from an MVC controller

After spending some time on this project, I believe I am getting close to a solution. My goal is to edit MVC application users using a Bootstrap modal and Angular for binding. I have set up a function in Angular to handle editing a user by passing their ID ...

Having trouble getting the toggle menu to work using Jquery?

I am trying to create a toggle menu using jQuery on this particular page: . The menu is located in the top right corner and I want it to appear when someone clicks on the "Menu ☰" button, and then disappear when clicked again (similar to this website: ). ...

Tips for updating the search textbox placeholder in a multiselect feature

Is it possible to modify the placeholder of the search textbox in the multiselect? I am referring to the textarea that allows you to search for an item by name. (see attached image) It is located below the selected elements. https://i.sstatic.net/fYuVz.pn ...

When viewed through the Firefox browser on an Android device, the text on the webpage suddenly enlarg

I currently have the following content displayed on my website: <div style="font-size: 11px; line-height: 17px; text-align: left;"> <p>lorem ipsum etc etc</p> </div> Strangely, despite setting the font size to 11px, the te ...

Is it possible for an AngularJS directive to compile a fresh element that has a second directive assigned to it?

UPDATE: All directives listed below will now require ng-model bindings to be applied in the elements they generate, targeting the controller assigned to the page. The code has been modified to reflect this. I am exploring the creation of dynamic HTML usin ...

Prevent the row height from fluctuating following the fadeOut() effect

Currently, I am facing an issue with two elements on my page: .start_over_button and .speed_buttons. In CSS, the .start_over_button is set to display: none, and in my JavaScript code, I have it so that when .speed_buttons are clicked, they fade out and the ...

Overflow leads to the entire page scrolling

My goal is to design a webpage that remains static without any scrolling. Some specific elements within the page may be allowed to scroll independently, but I am focused on preventing the entire page from scrolling. The main issue arises when a deeply nest ...

Text with Icon Fonts Does Not Align Vertically

I'm using icon fonts in a nav list and I want to place text between two of the icons. However, there's an issue with alignment - the icons are positioned higher than the text, causing them to not match up well. Is there a solution to this problem ...

There seems to be an issue with the fixed navigation menu in Bootstrap 4. I seem to be overlooking something that is causing this problem

I encountered an issue with my fixed navigation while using bootstrap 4. Everything works fine when hovering over non-active nav items, but it displays two bottom borders when hovering over the active nav item. I'm seeking assistance to resolve this i ...

The background image stubbornly refuses to stretch to the full width of the section container

Looking at my code example and the screenshot provided, it's clear that the image is not fitting into the container even when set to 100% width or utilizing other properties. Below you will see the code snippet: .about-us{ background-image: url(i ...

Is there a way to have a content's columns adjust to the size of an image?

I'm currently struggling with a layout issue. I have an image on the left and want the content columns on the right (title, lorem...) to adjust their height to match the image. How can I achieve this? I'm using Bootstrap v5.1.1 Current image: ...

Angular does not display results when using InnerHtml

I'm currently in the process of creating a weather application with Angular, where I need to display different icons based on the weather data received. To achieve this functionality, I have developed a function that determines the appropriate icon to ...