0

I've created a jsFiddle to illustrate the problem I am having with some images:

http://jsfiddle.net/77r41c5j/

The HTML for the dual column layout is like:

            <div style="">
                <div id="divContactTexas" style="width: 50%; float: left; background-color: red;">
                    Lorem ipsum 
                    <img src="http://brownfieldsubslab.com/texas.gif" />
                </div>
                <div id="divContactCalifornia" style="width: 50%; float: left; background-color: blue;">
                    Lorem ipsum 
                    <img src="http://brownfieldsubslab.com/california.gif"/>
                </div>
            </div>


            var texasHeight = document.getElementById('divContactTexas').scrollHeight;
            console.log("texasHeight:"+texasHeight);
            var californiaHeight = document.getElementById('divContactCalifornia').scrollHeight;
            console.log("californiaHeight:"+californiaHeight);
            var maxHeight = (texasHeight>californiaHeight) ? texasHeight : californiaHeight;
            console.log("maxHeight:"+maxHeight);    
            document.getElementById('divContactTexas').style.height=maxHeight+'px';
            document.getElementById('divContactCalifornia').style.height=maxHeight+'px';

I have a mockup page on the live site: http://brownfieldsubslab.com/contact.html

So then I am having a trouble mainly in Chrome where as I change the size of the browser window more and more narrow the images at some point when width of browser window is small starts to be cut off mainly in Chrome. I have experimented with just adding more pixels to the height it does alleviate the problem but I am wondering why the image gets chopped off is there a way to prevent this?

The problem starts to look like:

enter image description here

I have tried looking into if scrollHeight or which height to use that doesn't really seem to matter. It must be something else.

Thank You

1 Answer 1

1

http://jsfiddle.net/77r41c5j/4/embedded/result/

http://jsfiddle.net/77r41c5j/4/

function fixHeight(){
    //normalize to check
    document.getElementById('divContactTexas').style.height='auto';
    document.getElementById('divContactCalifornia').style.height='auto';

    var texasHeight = document.getElementById('divContactTexas').scrollHeight;
    console.log("texasHeight:"+texasHeight);
    var californiaHeight = document.getElementById('divContactCalifornia').scrollHeight;
    console.log("californiaHeight:"+californiaHeight);
    var maxHeight = (texasHeight>californiaHeight) ? texasHeight : californiaHeight;
    console.log("maxHeight:"+maxHeight);    
    document.getElementById('divContactTexas').style.height=maxHeight+'px';
    document.getElementById('divContactCalifornia').style.height=maxHeight+'px';
}

window.onload = fixHeight;
window.onresize = fixHeight;

Wrap your code in a function and call it whenever window is resized, initially call it when window loads.

And for the image cutoff, use css.

#left-side-image{
  width: 100%;
  max-width: 212px;
}

with CSS http://jsfiddle.net/77r41c5j/5/embedded/result/

http://jsfiddle.net/77r41c5j/5/

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

1 Comment

That's very interesting. I applied the CSS directly to the IMG TAG. The problem goes away. Thank you for posting this.

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.