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

CSS CSS Layout Techniques Flexbox Layout Build a Navigation with Flexbox

background-position

Hello,

It appears to me that we can use background-position to layout a page. Also, background-position uses negative properties to position elements on a page.

Could you please teach as simply as possible how to use background-position to layout a simple page with a navigation bar and 2 columns. Please use negative numbers to position some of the elements (that is the concept I am trying to understand)

thanks!

2 Answers

Chris Hall
seal-mask
.a{fill-rule:evenodd;}techdegree
Chris Hall
Full Stack JavaScript Techdegree Student 11,442 Points

background-position refers to the position of an image or images in relation to their container.

.box {
background-image: url('img/smile.png') no-repeat, url('img/pen.png') no-repeat, url('background.jpg');
background-position: left top, right bottom, center;
}

The above would have the smile.png in the top left corner of the container, with pen.png at the bottom right corner. Both are over the background.jpg image.

See video: http://teamtreehouse.com/library/css-foundations/backgrounds-and-borders/advanced-backgrounds-3

Or read more about the property at: https://developer.mozilla.org/en-US/docs/Web/CSS/background-position

thanks!