Set a Fixed div to 100% width of the parent container

前端 未结 7 1657
忘了有多久
忘了有多久 2020-12-09 00:52

I have a wrapper with some padding, I then have a floating relative div with a percentage width (40%).

Inside the floating relative div I have a fixed div which I w

7条回答
  •  独厮守ぢ
    2020-12-09 01:11

    Remove Padding: 10%; or use px instead of percent for .wrap

    see the example : http://jsfiddle.net/C93mk/493/

    HTML :

    Some relative item placed item

    CSS:

    body{ height:20000px }
    #wrapper {padding:10%;}
    #wrap{ 
        float: left;
        position: relative;
        width: 200px; 
        background:#ccc; 
    }
    #fixed{ 
        position:fixed;
        width:inherit;
        padding:0px;
        height:10px;
        background-color:#333;
    
    }
    

提交回复
热议问题