2

I'm working on a project for a large webshop, but I've run into a problem.

I need to put a div with width: 100% of the screen, inside a div with a fixed width of 960px.

    <div> /* This div is fixed to 960px */
        <div> /* This is the div I want to fit the screen width */
        </div>
    </div>

Normally I would put the element outside my content area, e.g. in the wrapper or whereever I already have a div with 100% width. But that would involve changing a template which affects all of my clients webshops, and I only need it on this one.

So; basically - How do a set a div to be 100% width of the screen, inside a fixed width parent? Is it even possible?

4

3 回答 3

3

如果固定 div 没有“位置:”样式,您可以添加position: absolute; width: 100%;到内部 div。我认为宽度百分比将与定位的下一个父级或屏幕相关。

于 2012-08-17T07:38:11.760 回答
0

这些 div 包含在具有相对位置的标题中,该标题由一些 jQuery 移动,以允许在将鼠标悬停在菜单中的特定品牌上方时显示横幅。

使用该方法,我的 div 将与具有相对 pos 的 div 相关,这也是 960px。

我开始意识到我唯一的选择可能是继续更改全局模板。

于 2012-08-17T07:45:45.453 回答
0

或者您可以使用宽度为 9999px 的伪元素,将其放置在 div 的左侧和右侧:before:after

在此处查看更多信息:https ://css-tricks.com/examples/FullBrowserWidthBars/

于 2014-05-20T12:36:53.210 回答