How can we protect the photo's proportion in web site?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • springage
    New Member
    • Mar 2010
    • 2

    How can we protect the photo's proportion in web site?

    This one just auto size the width
    But how can we auto size the height?
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    #Refresh#
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <style type="text/css">
    <!--
    body {
    font-size: 12px;
    text-align: center;
    margin: 0;
    padding: 0;
    }
    #pic{
    margin:0 auto;
    width:100%;
    padding:0;
    border:0px solid #333;
    }
    #pic img{
    max-width:100%; mywidth:expression(onload=function(){
    this.style.width=(this.offsetWidth >document.getElementById("pic").scrollWidth*8/10)? "100%": "auto"});
    
    border:1px dashed #000;
    }
    -->
    </style>
    
    
    </head>
    <body>
    <div id="pic">
    <img src="#PARAM1#" >
    </div>
    </body>
    
    </html>
    Last edited by gits; Mar 19 '10, 08:43 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    this will only work in IE ... and what is your exact question? you already have the logic and just need to set
    Code:
    this.style.height
    additionally in your expression.

    kind regards

    Comment

    Working...