简体   繁体   中英

How to maximize and minimize a div

How to maximize and minimize a div. Can I resize div according to as need.

I think you need something like this

http://jsfiddle.net/miqdad/Qy6Sj/1/

You can view the code in jsfiddle here is the code what I have done created a div with another div inside as title bar and content box

html

<div id="widnow">
    <div id="title_bar">
        <div id="button">-</div>
    </div>
    <div id="box">
    </div>
</div>

css

#widnow{
    width:400px;
    border:solid 1px;
}

#title_bar{
    background: #FEFEFE;
    height: 25px;
    width: 100%;
}
#button{
    border:solid 1px;
    width: 25px;
    height: 23px;
    float:right;
    cursor:pointer;
}
#box{
    height: 250px;
    background: #DFDFDF;
}

jquery

$("#button").click(function(){
    if($(this).html() == "-"){
        $(this).html("+");
    }
    else{
        $(this).html("-");
    }
    $("#box").slideToggle();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM