CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 20th, 2012, 10:42 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Image max-height question

Good day everybody.

I have a layout which looks like the attached PNG file.

As you can see, I have four DIVs:
  • PIC
  • CAPTION
  • CONTAINER
  • BODY

I have a max-height set on DIV ID pic so that it will only ever reach 400px in height. This is working OK; caption div will always appear below it and container will re-size accordingly. All the time, the text in "body" will wrap around to display the article text.

My problem is that some authors include images within the body text and don't display a side "pic" or "caption".

My question is, is it possible - using CSS - to limit images that appear in my "body" DIV to a max-height of 400px?

Thank you for reading and I hope that someone can offer me some help here!
Regards.
Attached Images
File Type: png 20-11-2012 16-31-34.png (30.4 KB, 37 views)
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253

"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984

Reply With Quote
  #2  
Old November 20th, 2012, 11:08 AM
simplypixie simplypixie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 104 simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
Not sure if it is semantically correct but have you tried (assuming here that you actually have a div called body as not sure if you mean the main body property)
Code:
body img {
  max-height: 400px;
}

Reply With Quote
  #3  
Old November 20th, 2012, 11:10 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Hi simplypixie

Thank you for the reply; sorry that's my mistake, the DIV I have called 'body' in my post here is actually called article_body .. I guess after hours of staring at a screen it must have just blended away .. I will give the code a go and see what happens!!

Thank you!

Reply With Quote
  #4  
Old November 20th, 2012, 11:41 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Quote:
Originally Posted by simplypixie
Not sure if it is semantically correct but have you tried (assuming here that you actually have a div called body as not sure if you mean the main body property)
Code:
body img {
  max-height: 400px;
}


OK, I have applied this but although the max-height seems to have worked, the image is now out of correct proportion

Is there a way to "crop" the image at 400px so as to keep the aspect ratio?

Thanks again!

Reply With Quote
  #5  
Old November 20th, 2012, 12:25 PM
simplypixie simplypixie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 104 simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
Not something I have done before, but what about adding in width: auto; to the css?

Reply With Quote
  #6  
Old November 20th, 2012, 01:49 PM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Quote:
Originally Posted by simplypixie
Not something I have done before, but what about adding in width: auto; to the css?


ahh, width auto ... I tried width:100% and that made the image expand to the full width of the div (I expected it to stay 100% of the image size).

Well, I'll give that a go tomorrow and see what happens.
MANY thanks for your help so far, it's really really appreciated!

Reply With Quote
  #7  
Old November 22nd, 2012, 09:22 AM
Akxe Akxe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 Akxe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 14 sec
Reputation Power: 0
Quote:
Originally Posted by badger_fruit
ahh, width auto ... I tried width:100% and that made the image expand to the full width of the div (I expected it to stay 100% of the image size).

Well, I'll give that a go tomorrow and see what happens.
MANY thanks for your help so far, it's really really appreciated!

I max-widht:x and max-height:y and it fited itself and kept the ration to the original

Reply With Quote
  #8  
Old November 22nd, 2012, 10:03 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Unfortunately, width:auto; didn't work either.
As it is, I've given up with this because it's taking too long and it was more of a "nice to have" thing than something we desperately needed.

I really appreciate your time in trying though, thanks all the same!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Image max-height question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap