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

前端 未结 7 1642
忘了有多久
忘了有多久 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:20

    You could use absolute positioning to pin the footer to the base of the parent div. I have also added 10px padding-bottom to the wrap (match the height of the footer). The absolute positioning is relative to the parent div rather than outside of the flow since you have already given it the position relative attribute.

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

    http://jsfiddle.net/C93mk/497/

    0 讨论(0)
提交回复
热议问题