Div为100%宽度的屏幕,但内部的父div具有固定宽度 [英] Div with 100% width of screen, but inside a parent div with fixed width

查看:117
本文介绍了Div为100%宽度的屏幕,但内部的父div具有固定宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要放置一个宽度为div的div:100%。我在一个大型网上商店的项目工作,但我遇到了一个问题。

 < div> / *这个div固定为960px * / 
< div> / *这是我想要适合屏幕宽度的div * /
< / div>
< / div>

通常我会将元素放在我的内容区域之外。在包装器或者我已经有一个div与100%的宽度。但是,这将涉及更改一个模板,影响我的所有客户网店,我只需要它在这一个。



基本上 - 如何设置一个div是屏幕的100%宽度,在固定宽度父?

$ p

解决方案

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


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?

解决方案

If the fixed div has no "position:" style you could add position: absolute; width: 100%; to the inner div. I think the width percentage will then relate to the next parent that is positioned or the screen.

这篇关于Div为100%宽度的屏幕,但内部的父div具有固定宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆