jakobk
jakobk

Reputation: 1132

CSS or jQuery on rails / How to "fill frame" with an image?

Whats the best technique for doing something like "fill frame" in indesign .. meaning take the image and scale the shortest side so it fits, then clipping the rest?

Is this possible with pure CSS ?

I am using Rails with jQuery..

The code could be something like this:

<div class="image_container"><img class="image" src=""></div>

Upvotes: 1

Views: 280

Answers (2)

Min Ming Lo
Min Ming Lo

Reputation: 2508

That assumes that the image is longer on its height than its width. It will have a blank space for landscape images.

Upvotes: 0

Meduza
Meduza

Reputation: 542

You can do it, if you had fixed size of image_container:

.image_container{
  width:200px;
  height:100px;
  overflow:hidden;
}

.image_container img{width:200px;}

This will scale image by width and hide by height.

Upvotes: 1

Related Questions