开发者

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>


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜