position:fixed and width:inherit with percentage parent

后端 未结 4 1451
清歌不尽
清歌不尽 2021-02-14 03:17

I\'m trying to give a fixed element a width of a percentage parent (here #container). When I use pixel instead of the percentage then it works

4条回答
  •  耶瑟儿~
    2021-02-14 03:30

    set the width of "fixed" to 100%, and give it (let's say) a position: relative instead of fixed. http://jsfiddle.net/J7yE4/

    #fixed {
        position: relative;
        width: 100%;
        border: 1px solid green;
    }
    

提交回复
热议问题