How to Achieve a Fixed Bottom Footer in Ember Framework

Hello, I am working on an Ember application and trying to implement a Sticky Footer feature. I followed a tutorial on Sticky Footer On CSS-Tricks which worked for me previously, but it seems to not work with Ember.

Here is my CSS code:

.mainFooter {
     height:100px;
     color:white;
     background-color: #0c2635;
     text-align:center;
}
.wrapper {
    min-height: 100%;
    margin-bottom: -100px;
}
.wrapper:after {
    content: "";
    display: block;
}
.mainFooter, .wrapper:after {
    height: 100px;
}

This is snippet from my HTML:

<footer class="mainFooter">
    SOME TEXT
</footer>

I inspected the source code using Developer Tools and noticed that Ember adds its own wrapper around the content from the application.hbs file, which includes a class called ember-view. So, I tried this:

.ember-view {
    min-height: 100%;
} 

Unfortunately, this did not resolve the issue as the footer appears in the middle of the page. Has anyone successfully implemented a Sticky Footer in an Ember app before? I would appreciate any suggestions to fix this problem.

I have uploaded the app to my server since I am not sure how to create an Ember demo on jsfiddle/codeopen. Here is the link:

EDIT
Following the suggestion by user kumkanillam, I made some changes:

In Application.hbs:

{{outlet "modal"}}
{{partial "header"}}
<div id="gif" class="wrapper">
    {{outlet}}
</div>
{{partial "footer"}}

In app.js:

App = Ember.Application.extend({
    modulePrefix: config.modulePrefix,
    podModulePrefix: config.podModulePrefix,
    rootElement: '#gif',
    Resolver
});

However, I encountered this error in the console:

ember.debug.js:43272Uncaught TypeError: Cannot read property 'tagName' of undefined

Can someone help me figure out what went wrong?

Answer №1

.ember-view is automatically included for all ember components, so it's not recommended to apply CSS properties directly to this class.

There are multiple approaches, but the following method should be helpful:

To ensure that your application.hbs content renders within a page-wrap div, you can wrap it as follows:

Add the following line in your index.html:

<div id="app-name" class="wrapper">
    {{content-for "body"}}
</div>

In your application.hbs:

<h1> Content </h1>
{{outlet}}  
<div id="footer">
  <p>I'm the Sticky Footer inside application.hbs</p>    
</div>

Ensure to configure the rootElement in your app.js, forcing the entire app to include it in the app-name div:

In your app.js:

App = Ember.Application.extend({
    modulePrefix: config.modulePrefix,
    podModulePrefix: config.podModulePrefix,
    rootElement: '#app-name',
    Resolver
});

Update your app.css with the necessary styling:

#wrapper {
    min-height: 100%;
    overflow: auto;
}

#footer {
    position: absolute;
    bottom: -3px;
    left: 2px;
    right: 2px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
}

Final Update:

No changes needed in app.js. Refer to the provided sample twiddle for assistance: SAMPLE TWIDDLE

Answer №2

If you're looking for a solution that utilizes flexbox, the following code may come in handy. While flexbox might be unfamiliar to some, this answer could serve as a useful resource for future reference.

For those interested, here's a codepen showcasing minimal content within the main body: http://codepen.io/anon/pen/KgXgjV

Alternatively, you can explore the same CSS with a more substantial amount of content in the primary area by visiting: http://codepen.io/anon/pen/dpVpBK

Demonstrating why position: absolute may not be the best approach is an example accessible via:

HTML

<html>
<body>
  <div id="root" class="ember-application">
    <div id="ember332" class="ember-view">
      <div class='main-content'>
      <h1>Welcome to Ember Twiddle</h1>
        <br />

        <p>
          this page has very little content
        </p>
      </div>
      <div id="footer">
        <p>I'm the Sticky Footer. inside application.hbs</p>
      </div>
    </div>
  </div>
</body>
</html>

CSS

/* this is just to reset codepen */
/* probably not necessary on ember */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* end reset */


html, body, #root {
  height: 100%;
}

.ember-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: lightblue;
}

.main-content {
  flex: 1;
}

#footer {
  width: 100%;
  height: 50px;
  background-color: grey;
}

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

Disable automatic focusing for a material-ui popover component

I am struggling to create a search match list that updates as the user types in their query. However, I am facing an issue where the input element loses focus to the pop-up. I have attempted to programmatically set the focus using refs, but I am unable to ...

Animate failed due to the appending and adding of class

$('#clickMe').click(function() { $('#ticketsDemosss').append($('<li>').text('my li goes here')).addClass('fadeIn'); }); <link href="http://s.mlcdn.co/animate.css" rel="stylesheet"/> <script ...

The Stylish Choice: Materialize CSS Dropdown Selector

I am currently integrating Materialize CSS into my application and have used media queries to ensure that the layout is responsive. However, I am facing an issue with a select dropdown element. It works fine on laptops but does not allow for selecting any ...

Date Selector Tool for Input Field

Does anyone know how to change the color of the date picker that appears in certain browsers but is unsure about the selector's name? HTML: <form action="pledge.html" method="post"> <input type="date" id="birthday" name="user_bda ...

Hide the scrollbars on the sidebar

I'm attempting to recreate a sleek scrollbar that caught my eye on the website . To achieve this, I need to have a screen larger than 955px in order to display the sidebar. However, when my sidebar overflows in the y direction, it causes an additional ...

EmberJS - how to register a precompiled handlebars template

In my EmberJS application, I have precompiled all of my handlebars templates so that they are loaded as pure Javascript files. However, I am encountering an issue where these precompiled templates are not being added to the Ember container as expected. In ...

Integrating dynamic PHP echo strings from a database into an established CSS layout

I am currently exploring PHP and MySQL databases, and I have managed to develop a basic search engine for my website. However, I am facing an issue that I am struggling to resolve: Is there a way to integrate the PHP echo output (search results) into the ...

Creating customized JQuery UI tabs to perfectly accommodate the available horizontal space

Can JQuery UI Tabs be modified to fill the horizontal space and stack to the left? In order to achieve this, could we consider using a markup like the one below: <table width="100%"> <tr> <td> ...content... </td> ...

The correct alignment of images is crucial for a website's overall aesthetics and functionality

My column displays images aligned in the center when viewed locally, but the alignment changes when hosted remotely. Here is the image when locally hosted: https://i.sstatic.net/I56Dg.png And here is the remote host image: https://i.sstatic.net/ePoAn.p ...

Which selector in CSS is applicable for targeting Bootstrap tooltips?

After some experimentation, I've mastered the functionality of Twitter Bootstrap Tooltips and am now focused on customizing their appearance. Previous inquiries into other plugins revealed specific CSS selectors - for example, jScrollPane had a track ...

Closing the space between navigation bar choices

I'm currently working on my website's navbar menu and struggling to eliminate the gap between each of the navbar links. It seems that the li attributes with the class dropdown are slightly wider than the rest of the links, causing this issue. I&a ...

What is the best way to modify the styling of my CSS attributes?

I'm currently working with this CSS code: input:checked + .selectablelabel .check { visibility: hidden; } Now, I want to change the visibility property to "visible" using JavaScript. I attempted the following: $(document).on('click', & ...

Fluid Grid System with columns of specific dimensions

Recently delving into the world of Foundation Framework, I've just begun utilizing it for my projects. My current task involves crafting a responsive design with the help of the Foundation Grid system. Specifically, I've set up a grid layout for ...

Using two body tags in the code of a Wordpress site can lead to malfunctioning

I've encountered a strange issue with my Wordpress sites hosted on BlueHost. There seems to be a double <head> tag appearing in the HTML code, even though there is only one. This duplicate tag is causing issues with the proper rendering of the s ...

Enhance your website navigation with Bootstrap Scrolling Nav: maintain consistent section heights and highlight the active

Can you help me with an issue I'm having when clicking on the <a> link in the navigation? The anchor point seems to be misplaced as the section headline (<h2>) is not visible. Is there a way to highlight the <a> links, perhaps by add ...

I am struggling to find the right way to center those images

https://i.sstatic.net/aRkvl.jpg Hello everyone, I'm currently attempting to set up the main content of the homepage resembling the image provided, but I'm encountering some challenges. Every approach I take seems to cause the image to overflow ...

Send JavaScript variable using a query parameter

I am working on passing a JavaScript variable across all pages in my project. The goal is to calculate the total value from various pages and display it at the end of navigation. Below is an example of my JS code: <script> $(document).ready ...

External elements - My physical being is in a state of chaos

Hello there, I hope everything is well with you. I have been working on creating a form using MaterializeCss to calculate an invoice for a craftsman. The user is required to input a number or select an item. Everything seems to be going smoothly so far. ...

To avoid truncation issues, consider inserting a plus sign following the ellipsis in the text-overflow property

Hey there! I have a table that contains some text and I'm looking to shorten the text after it reaches a certain length. I was able to achieve this using the text-overflow property. .overflow { width: 70px; overflow: hidden; text-overflow: elli ...

Is it possible to create an index.html page with all the necessary head tags to prevent duplicate code across multiple html pages?

Imagine I am using app.js or a Bootstrap CDN link for all of my HTML pages, but I don't want to include it in every single page individually. Is there a way to create an index.html file that includes this so that all other HTML pages load the head fro ...