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

How do you center a background image in a slider?

<div id="slider" class="sl-slider-wrapper">

                <div class="sl-slider">

                    <div class="sl-slide bg-1" data-orientation="horizontal" data-slice1-rotation="-25" data-slice2-rotation="-25" data-slice1-scale="2" data-slice2-scale="2">
                        <div class="sl-slide-inner">
                            <img src="img/1.jpg">

                        </div>
                    </div>
</div>

i know it's background-size: cover; but I don't know which class to target

1 Answer

Like that, I would say you have to apply your css rules to .sl-slide.bg-1". You should simply try and see what fits the best. You risk nothing if ever you are wrong :) !

thanks, but I can't seem to get background-size:cover to work. Ive done it before but this one doesn't work :/

Would you have the projet you are working on, online ? I might probably help you this way easily.

It's okay. I found my backup files. That one works. Thanks