Reputation: 155
I have created a image tile for which i have set a background image. But when i re-size the tile image on the background also gets re-sized, is there a way to make the background image stay to full image regardless of the tile size. The ratio doesn't matter. I only need the tile to display the full image.
.activity-image {
border-radius: 12px;
width: auto;
height: 210px;
background-image: url('http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg');
background-size: cover;
}
.tile {
background-color: #ffffff;
border-radius: 12px;
height: auto;
margin: 0 auto;
}
<div class="tile">
<div class="activity-image "></div>
</div>
jsfiddle - https://jsfiddle.net/9hy3mcun/8/
Upvotes: 1
Views: 48
Reputation: 2040
You can specify min-width for activity-image and set .title to overflow:hidden.
.activity-image{
border-radius: 12px;
width: auto;
height: 210px;
background-image: url('http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg');
background-size: cover;
background-repeat: no-repeat;
min-width: 900px;
}
.tile{
background-color: #ffffff;
border-radius: 12px;
height: auto;
margin: 0 auto;
overflow: hidden;
}
Upvotes: 0
Reputation: 122027
You can use background-size: 100% 100%
instead. First value is width
and second is height
of background.
.activity-image {
border-radius: 12px;
width: auto;
height: 210px;
background-image: url('http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg');
background-repeat: no-repeat;
background-size: 100% 100%;
}
<div class="tile">
<div class="activity-image "></div>
</div>
Upvotes: 2