Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can the minimum height be set by javascript? 1

Status
Not open for further replies.

starblood

Technical User
Feb 28, 2001
63
0
0
GB
I can set the height of my element by using this code:

document.getElementById("container").style.height='100px'

does anyone know the syntax to set the minimum height (if indeed it can be done)?
 
Yup, it can be done:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript"></script>

<style type="text/css">

div {
   width:200px;
   border:3px solid red;
   margin-bottom:25px;
}

</style>

</head>
<body>

<div id="test"></div>
<input type="button" onclick="document.getElementById('test').style.minHeight = '200px'" value="set min height" />

</body>
</html>

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Appreciated kaht.

I did try 'minheight' but didn't factor the case sensitivity. Javascript can be so unforgiving.

Thanks a lot!
 
I did try 'minheight' but didn't factor the case sensitivity.

Most css properties can be set by javascript by removing the dash and changing the following letter to upper case.

for example:

border-left -> borderLeft
margin-right -> marginRight
background-color -> backgroundColor
etc...

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Most css properties can be set by javascript by removing the dash and changing the following letter to upper case

Great tip - thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top