How can I adjust DIV width to contents

前端 未结 5 1630
一向
一向 2021-01-31 14:59

I have a div element with style attached:

.mypost {
    border: 1px solid Peru;
    font-family: arial;
    margin: auto;
    min-width: 700px;
    width: 700px;         


        
5条回答
  •  灰色年华
    2021-01-31 15:09

    EDIT2- Yea auto fills the DOM SOZ!

    #img_box{        
        width:90%;
        height:90%;
        min-width: 400px;
        min-height: 400px;
    }
    

    check out this fiddle

    http://jsfiddle.net/ppumkin/4qjXv/2/

    http://jsfiddle.net/ppumkin/4qjXv/3/

    and this page

    http://www.webmasterworld.com/css/3828593.htm

    Removed original answer because it was wrong.

    The width is ok- but the height resets to 0

    so

     min-height: 400px;
    

提交回复
热议问题