There are two things that might be the issue. The first may be that your li
is not filling the area of the .slider
list. You can add height: 100%
and width: 100%
to the list items see if that fixes the issue. The other problem might be that your browser doesn't support background-size: cover
. If that is the case you can try the proprietary browser tags for it:
.slider li {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-size:100% 100%;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader
(src='image/path/name.png',sizingMethod='scale');
}
If that doesn't fix the issue, you can always go the route of putting the images in the HTML as DOM elements. You can then just write your CSS to say `'width: 100%' and they will always fill the parent width. This does lead to some issues with centering the image, but it will get the job done!
Based on your HTML update
The problem is that the property background-size: cover
only works if you define the image using the background-image: url(../path/to/file.jpg)
. Since the images are DOM elements, they are not considered backgrounds, rather they are just block level elements. You could either rewrite your CSS to handle HTML images or you can change your HTML to this:
<ul class="slider">
<li style="background-image: url('after_front.jpg');"></li>
<li style="background-image: url('after_scenicView.jpg');"></li>
<li style="background-image: url('after_lib.jpg');"></li>
<li style="background-image: url('after_mac.jpg');"></li>
<li style="background-image: url('after_gym.jpg');"></li>
<li style="background-image: url('after_lounge.jpg');"></li>
</ul>
The paths to your images might not be right, so you should check to make sure that you aren't getting 404 errors on them. Also, since they are not DOM elements anymore, you will have to define a height in your CSS.