Code for controlling the height of page elements (JS) written to netizens)
Source: Internet
Author: User
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head >
< Title > No title page </ Title >
< Script Type = "Text/JavaScript" >
Function $ (ID)
{
ReturnDocument. getelementbyid (ID );
}
Function SS ()
{
VaR WD = $ ( " AA " );
// WD = WD. tostring (). substr (0, 3 );
For ( VaR I = 1 ; I < WD. childnodes. length; I ++ )
{
VaR Wdh = WD. childnodes [I]. clientheight;
// Alert (wdh );
If (Wdh > 200 )
{
WD. childnodes [I]. style. Overflow = " Hidden " ;
WD. childnodes [I]. style. Height = " 200px " ;
// Alert (document. getelementbyid ('A'). style. width );
}
}
}
</ Script >
< Style >
# Aa {} {Clear:Both}
# Aa Div {} { Float : Left ; Display : Inline ; Margin-left : 15px ; }
. Bor {} {Border:1px solid # dddddd;}
</ Style >
</ Head >
< Body Onload = "SS" >
< Div ID = "AA" >
< Div Style = "Height: 10px ;" Class = "Bor" > DSAS </ Div >
< Div Style = "Height: 400px; Background: blue" Class = "Bor" > Sculptor Sikla </ Div >
< Div Style = "Height: 200px; Background: # cccccc ;" Class = "Bor" > Dsafdsaf </ Div >
< Div Class = "Bor" > Location </ Div >
< Div > Unit Russia </ Div >
< Div Class = "Bor" > Fe </ Div >
< Div Class = "Bor" > Wewrew </ Div >
</ Div >
< BR />
< Div Onclick = "SS ()" Style = "Clear: Both; Border: 1px solid # dddddd; Background: # d5d5d5; width: 100px ;" > Click adaptive </ Div >
</ Body >
</ Html >
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.