Issues with Flexbox functionality in Aurelia app using the webpack starter kit

When using basic HTML with flexbox, it is possible to create a layout with a header, footer, and content area that fills the space in between:

<html>
   <body style="display:flex;flex-direction:column;flex-grow:1">
      <div style="display:flex;flex-direction:row">Header</div>
      <div style="display:flex;flex-direction:row;flex-grow:1">Content Area</div>
      <div style="display:flex;flex-direction:row">Footer</div>
   </body>
 </html>

The header appears at the top, and the footer at the very bottom.

+++++++++++++++++++++
+ Header
+ Content Area
+
+
+
+
+ Footer
+++++++++++++++++++++++++

However, when attempting to achieve the same layout within Aurelia (using the webpack starter kit), the grow property seems to be ignored on both the body and the content elements.

index.ejs -- included in the starter kit I made some styling additions:

<body aurelia-app="main" style="display:flex;flex-direction:column;flex-grow:1">

app.html -- changes made to the original starter kit file:

<template>
   <div style="display:flex;flex-direction:row;">Header</div>
   <div style="display:flex;flex-direction:row;flex-grow:1">Content Area</div>
   <div style="display:flex;flex-direction:row;">Footer</div>
</template>

I also attempted adding flex to

<template style="display:flex;flex-direction:column;flex-grow:1">

Although everything looks correct when inspecting the page — almost identical to the basic HTML example — the body and the div containing the Content Area do not expand to fill the height of the page.

Trying to create an example in Plnkr revealed the same issue as observed in Aurelia. I noticed that Plnkr utilizes shadow elements just like Aurelia does — this may be related to the problem?

Answer №1

To ensure compatibility with Aurelia (or on its own), the markup should be structured in this way:

<body aurelia-app="main" style="height:100vh;margin:0;display:flex;flex-direction:column;">
  <my-template style="display:flex;flex-direction:column;flex-grow:1">
    <div style="display:flex;">Header</div>
    <div style="display:flex;flex-grow:1">Content Area</div>
    <div style="display:flex;">Footer</div>
  </my-template>
</body>

In this structure, the <template> must be replaced with <my-template> to render properly, as the <template> tag has a specific function and will not display visually. Refer to MDN for more information: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template.

Additionally, the body element (or any main element) should have a set height, as demonstrated by height:100vh in this example.

Moreover, keep in mind that the flex-grow property applied to the <body> will only work if its parent, the <html> element, also has display: flex set.

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

Having trouble selecting the first td within a tr using CSS3 selectors

I'm encountering an issue with selecting the first td in the tr of a dynamically generated table. I've attempted to do this using: .record_list tbody tr td:first-child { text-align: center; } However, the styles are not being applied as ex ...

Tips for implementing an external CSS file to set a background image in gedit

Even though I am enrolled in HTML and CSS classes, one aspect of external CSS that continues to baffle me is how to create a background image. I can successfully implement external css in other ways, but incorporating a background image has proven to be ch ...

Using the radius to determine the center point of the circle

<span class="qs">Q{{i + 1}} <a href="#question-view"></a></span> <div class="tooltipp text-center bubble[ngStyle]="bubbleStyle(prof?.proficiencyBrightness, prof?.proficiencyRadius)"> </div> In the illustration below, ...

Eliminated the gap among the whitespace buttons within a bootstrap dialog

I am currently working on a web application using Bootstrap 3.3.7 and Bootstrap Confirmation 2.4.1. The confirmation function works effectively, but I have noticed that when the button (Delete) with the Confirmation is clicked, it results in some spacing i ...

Setting the width of colspan elements can be challenging when other columns have dynamic widths

I am working with a table setup that includes various columns for data tracking: <table > <thead style="width: calc(100% - 15px); display: table; table-layout: fixed;"> <tr> <th colspan="3">& ...

A modern CSS solution for a fixed columns and header layout in a scrollable table

How can I create a table with minimal JavaScript using modern CSS? I am aiming to include the following features: Fixed column(s) (positioning and width) Scrollable in both X and Y axes Responsive in the X axis (for non-fixed width columns). https://i. ...

Error with hyperlinks preventing redirection when clicking on the menu

$(document).ready(function () { $('.mobile-nav-button').on('click', function() { $( ".mobile-nav-button .mobile-nav-button__line:nth-of-type(1)" ).toggleClass( "mobile-nav-button__line--1"); $( ".mobile-nav ...

Using Internet Explorer will display a vastly different blueprint site compared to what you see on Firefox or

I've been utilizing the Blueprint CSS framework for my website development in order to ensure compatibility across different browsers, but unfortunately it's not rendering properly in IE. The main body is off-center, the image positioning is inco ...

There seems to be a problem with the while loop in the PHP code while creating a forum

Encountered a new error that says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND type='o'' at line 1. Can someone assist in fixing this issu ...

Send a POST form from my website to another website and retrieve the data from the remote server

My website, example.com, includes a web HTML form that leads to another site where the results are currently displayed. I want to retrieve these results from the other website using PHP or some other method and showcase them on my own site. However, the fo ...

Automatically activate click events based on modifications in certain div classes - must be repeated in a loop

When a user makes changes within the .ap-create-story-panel-wrap div and then clicks outside of that specific div, I want to trigger a button click in my function. I am currently using the data-panel attribute as the selector for the container variable. I ...

Default display as collapsible. Prefer them to be concealed initially

Looking for help with creating collapsible buttons. Currently, they show and collapse onclick, but I want them to be hidden by default. This is part of a personal website project where I am teaching myself HTML. What do I need to change? I tried using butt ...

Why does the image resize with the window, yet a black bar appears on certain sizes?

Recently, I encountered a coding challenge where I needed to resize an image based on the window size of the web browser it's being viewed in: <p> <a href="www.link.com"> <img src="/images/image.png" style="max-height: 235px; ...

Menu options moved to the right of the screen

I am encountering a small issue with my dropdown menu that I can't seem to solve. The first item in the dropdown menu appears correctly, but the second item is slightly shifted to the right. It seems like the margin-right applied to the link may be c ...

Coordinated Tab Navigation

Two tabbed navigations are present, one at the top and one at the bottom. Targeting the div through classes allows for relevant content to be displayed in both. Clicking the "Business" tab should show user-relevant information on both the top and bottom t ...

Issue with the Animated Skill Bar not functioning properly when scrolling

I've been trying to implement an animated skill bar in my Portfolio using JQuery, but I'm facing some challenges. Despite following various tutorials, the code doesn't seem to work as expected. I've tried calculating section scroll posi ...

Could an image displayed with {display: table-cell} be a potential issue?

I am exploring the use of CSS properties display: table-* to style a list of photos. The code below is intended to demonstrate this implementation, but there seems to be an issue with the table layout in Firefox and Safari as indicated by the borders appea ...

I'm looking to generate a semicircle progress bar using jQuery, any suggestions on how

Hi there! I'm looking to create a unique half circle design similar to the one showcased in this fiddle. Additionally, I want the progress bar to be displayed in a vibrant green color. I've recently started learning about Jquery and would apprec ...

Show on smartphones, conceal on desktops - Activation/URL

I'm attempting to create a click-to-call link on my website using the following: <a class="mobile-only" href="tel:+534306464456"><p class="">Click Here to call us</p></a> I want this link to only show up on mobile devices, sp ...

How to perfectly align a CSS block

This snippet of css is responsible for positioning a group of third-party images that are dynamically created as part of a JavaScript slider. I am looking to center these images based on the alignment of another image located elsewhere on the page. I hav ...