4

I want to put a 100% height image in my front page that fills the whole screen, and then show other images and text when scrolling. I followed this guide to do so:

Demo: http://www.minimit.com/demos/fullscreen-backgrounds-with-centered-content

Explanation: http://www.minimit.com/articles/solutions-tutorials/fullscreen-backgrounds-with-centered-content

The issue is that, as far as I am concerned, if you want to have a div that is 100% the height of the browser window, you need to give 100% height to all its parent elements. Therefore, in order to make this work in angularjs I have given 100% height to html, body and ng-scope (using min-height:100% does not work).

The problem is that having height:100% in the ng-scope class leads to some unwanted behavior. For example, if I want to add a footer (which is static, outside the ng-view directive), the footer is displayed right after the first 100% height, instead of appearing at the end of the page, something like what I simulated here:

http://jsfiddle.net/x3zbufhk/

by simulating the ng-scope class with:

#ng-scope {
    height: 100%;
    background-color:red;
}

So, is there any way of having 100% height divs in angularjs without modifying the height of ng-scope?

Thanks a lot!

EDIT: By 100% height div, I mean a div that is 100% height of the browser window.

5
  • 100% height = 100% document height? Commented Jan 4, 2015 at 12:28
  • Yes, sorry because it is probably unclear. I want a div that is 100% the height of the browser. Thank you! Commented Jan 4, 2015 at 13:48
  • The minimit website isn't loading for me. Are you looking for something like this? On a side note, using #ng-scope is the ID ng-scope not the class. Commented Jan 4, 2015 at 14:22
  • Hey, thanks a lot for your answer. I want this behavior for long content inside the .ng-scope class: jsfiddle.net/getg811q and this behavior for short content: jsfiddle.net/hcpr96ar . But I don't know how to accomplish this, since for the short content you need html, body and ng-scope to have height:100%, while for the long content the footer is wrongly placed with that configuration: jsfiddle.net/x3zbufhk Commented Jan 4, 2015 at 20:05
  • Did you ever manage to solve this? I'm facing the exact same problem Commented Jul 16, 2015 at 20:31

4 Answers 4

5

This is a bit hacky, and doesn't entirely answer your question (how to do this without modifying ng-scope), but it does work.

html, body, .ng-scope {
  height: 100%;
}

Or with Bootstrap

html, body, .ng-scope, .container-fluid, .row {
  height: 100%;
}
Sign up to request clarification or add additional context in comments.

Comments

1

Just use min-height: 100% instead of height: 100% on #ng-scope FIDDLE

1 Comment

Hey, thanks a lot. For some reason using min-height in .ng-scope does not work to make the image 100% size of the window (following the tutorial that I linked), but you are totally right it works with the text that I used to simulate the issue in fiddle. Let me try to figure out why...
1

Here's how I fixed this problem while using Wijmo FlexGrid and AlgularJS.

I'm trying to edit a multi-line textarea within the celltemplate of my grid. When I get into edit mode then wijmo inserts a div around my textarea with a class of ng-scope. As you noticed changing the .ng-scope { height: 100% } royally screws with your whole page. If you use the F12 / Developer tools in your browser you can inspect the elements around the attribute you are trying to resize. In my case it looked like this:

devtoolsimage

the offending div was ng-scope which had a height of 144px.

I added to my site.css an override based on the nested class .wj-cell .ng-scope

enter image description here

This will only modify ng-scope when its parent has a class of wj-cell.

Comments

1

Instead of using

{
height : 100%
}

try this instead

{
height: 100vh;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.