0

[CONFIRMED: IE9 suffers the same bug! :'( ]

I have a div that is like a photo-frame style thing, which contains an img, and two divs. This outer div has a max-width (80%) that works beautifully.

Problem is, if I set a max-height, I get the following behaviour:

  • 80px - works as expected.
  • 80em - works as expected.
  • 80% - same as height:auto and no max-height.

Any advice? Doc-type is <!doctype html>, which is entirely valid, and normally works perfectly. I even added <meta http-equiv="X-UA-Compatible" content="IE=9"> out of frustration.

EDIT:

This here is the html/css that I believe is relevant:

<!doctype>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9"> 
<script type="text/javascript" src="https://getfirebug.com/firebug-lite-beta.js"></script>
<style type="text/css">
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
body
{
    background-color:black;
    color:black;
    font-size:80%;
    font-family:'Merriweather',georgia,serif;   
    max-width:1600px;
    min-width:780px;
    text-align:center;
    margin:0 auto;
    line-height:1.1;
}
div#container
{
    text-align:left;
    padding:1em 15px;
    margin:2em 5px;
    position:relative;
    background:#FFE4BE;
}


div.image
{
    background:white;
    max-width:80%;
    max-height:20%; <--- HAS NO EFFECT!
    overflow:hidden;
    margin:0 auto;
    display:block;
    padding:2em 2% 1em 2%;
}
div.image img { width:100%; margin:0 auto; display:block; }
div.image div.title { font-size:160%; font-weight:bold; text-align:center; margin-top:0.25em;  }
div.image div.caption { font-style:italic; text-align:center; }
</style>
</head>
<body>
<div id="container">
<div id="body">
<div class="image">
<img src="construction.jpg">
<div class="title">Construction</div>
<div class="caption">
<p>Turns out, we're not ready for beta users yet.</p>
<p>We'll have a mailing list available soon. Check back periodically!</p>
</div>
</div>
</div>
</div>
</body>
</html>
2
  • Can you post the CSS and HTML on here? Commented Feb 10, 2011 at 2:23
  • this only works in firefox, chrome also will not do what you are trying. Commented Feb 10, 2011 at 11:02

3 Answers 3

0

You need to take a new approach to this - using max-height to scale an image is simply the wrong way to go about it, and you will most likely never get to a point where you like the solution.

If I was you, I'd go back to the drawing board and rethink the layout (not the design, just the markup & css) and try to reach the design goal another way.

Sign up to request clarification or add additional context in comments.

2 Comments

yeah I'm tossing up other designs actually, but any examples of what you're suggesting?
@dawmail333: Firstly i'd forget about working with heights and widths. then i'd go one of two ways. 1) work with paddings/margins on containing elements. 2) work with positioning. it really depends on the image content you are using, and weather or not you wish the containers to collapse around small images for example.
0

Use * html for ie.

* html .whatever{
height:100%;
}

3 Comments

not really following. What does height:100%; achieve? Does it trigger some quirk that makes max-height:##%; work?
@dawmail333 - this is the star hack, which triggers this CSS to work in IE but ignored in other browsers. There are some IE height and width bugs that can be fixed with this hack. I was under the impression they were mainly IE6 bugs, but it may be worth a try.
* html before height:100% is ignored by other browsers and only affects IE. It's a hack that fixes 100% height
0

For what you're doing, it'd be easier to just set the image container to have a nice margin and set the max width to 100%. You probably don't want to force the max-height to be smaller than the viewport anyways since people are accustomed to scrolling vertically to see large/long images.

1 Comment

Mm, I'll look into that idea, but I'm sure that max-height doesn't work anyway, and I'll be wanting to make this work nicely with mobile browsers, in which case, well... Nothing's set in concrete though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.