Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

html - Constraining image height with bootstrap responsive image?

Working on a site using bootstrap, in the portfolio section, the images of projects are responsive with :

'class' => 'img-responsive'

It works great for landscape images, the portrait images are blown up to fit width wise, but are too tall, is there a way to check for a portrait orientated image and just apply a fixed height of 600px for it?

question from:https://stackoverflow.com/questions/19708979/constraining-image-height-with-bootstrap-responsive-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If the container should have a fixed height, then give it an ID (or a class) and change the .img-responsive restrictions the other way around eg

.container {
height: 600px;
}


/*And then change */
  .container .img-responsive {
    display: block;
    height: auto;
    max-width: 100%;
}  
/*To */

.container  .img-responsive {
    display: block;
    width: auto;
    max-height: 100%;
}

Not sure how it will work with a mix of orientations but if they are floated it shouldnt really matter


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...