小编Ala*_*leh的帖子

如何使固定的div继承父级的宽度?

有没有办法固定定位div可以继承父级的宽度?

我知道固定宽度是相对于窗口的,所以这段代码不起作用:

#wrapper{
        position: relative;
        width:500px;
        height: 20px;
        background-color: blue;
}

#header{
        position: fixed;
        width: 100%;
        height: 20px;
        background-color: rgba(255,0,0,0.5);
}
Run Code Online (Sandbox Code Playgroud)
<div id="wrapper">
  #wrapper
        <div id="header">
          #header
        </div>
    </div>

    
Run Code Online (Sandbox Code Playgroud)

html css fixed width

7
推荐指数
1
解决办法
7748
查看次数

标签 统计

css ×1

fixed ×1

html ×1

width ×1