Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nils Garland
18,416 PointsResponsive full screen image
Hi, I want to make a website and I need an image at the top of the page. No matter what screen size it needs to cover the entire page until you scroll. An example would be this page here http://www.qualium-systems.com/. Thanks to any help! :)
2 Answers
David Perkins
9,607 PointsFrom my experience there's a couple of ways you can achieve this. Quickest way would be to have a full width/full height container and just bang everything in there, or you could use a plugin such as fullPage.js.
I've just written something out on Codepen for you to have a look at here. So i'd probably go with something like this though if you're wanting to do it all without using plugins?
Jacob Herrington
15,835 PointsThe absolute simplest way to do this is to have:
<div>
</div>
div {
width: 100%;
height: 500px; // set this to whatever you want.
background: url("your-image.jpg") no-repeat center;
background-size: cover;
}
The example you posted is using a CSS framework called Twitter Bootstrap. It is the most commonly used CSS framework and once you have an understanding of CSS, you should learn it!
Also, to add on to what David said -- you can do this with JS, but it is much slower and harder on a client computer than using CSS.
Nils Garland
18,416 PointsHi Jacob! I am solid in CSS and Bootstrap but never came around to doing this. I learnt a lot before I started here at treehouse, thanks for responding :D
David Perkins
9,607 PointsDavid Perkins
9,607 PointsJust as a sidenote... that Codepen is very, very basic and should only be used just give you the simplest understanding of how to make a full height responsive section at the top of your page. You'll need to obviously factor this into your design and tweak it to fit any other ideas you have.
Hope it helps though :)
Nils Garland
18,416 PointsNils Garland
18,416 PointsCheers, David!