Jump to content

Bootstrap help


Heartless
 Share

Recommended Posts

Been working with bootstrap recently and have come across something that I'm struggling with. I'm trying to set the height of an image differently depending on the screen it is being used on. For example if I had a picture at 200px I want it to resize to 100px when I resize the screen to view on a mobile.

 

Perfect example of what I'm trying to do here: http://frogspark.co.uk

 

How do I go about getting the image to resize when making the window smaller? Is it done with css or javascript.

Link to comment
Share on other sites

I have used the background-size property and set it to cover, and yes it does make the image responsive. But I was just wondering how they made the div size change depending on the screen size. When I go on that site and resize the window from large to medium the cover image height shoots down and does the same when it goes to mobile view.

Link to comment
Share on other sites

You can use media queries to set the height of something explicitly.

.object {
  height: 200px;
}

@media (max-width: 1024px) { /* Devices up to 1024 pixels wide */
  .object {
    height: 100px;
  }
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...