扩展超出容器div的子div [英] Extend child div beyond container div

查看:156
本文介绍了扩展超出容器div的子div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用浏览器的宽度扩展这个div。我已阅读
这里
,你可以使用 {position:absolute; left:0; right:0;} 来实现,就像在jsfiddle中一样:
http:// jsfiddle。 net / bJbgJ / 3 /



但问题是我目前的 #container code> {position:relative;} 属性,因此如果我将 {position:absolute} 只能参考 #container 。有没有办法仍然延伸我的孩子潜水超过 #container

解决方案

我可以想出五种可能达成目标的方法:


  1. 在内部元素上使用负边距移动


  2. 使用Javascript将内部元素移动到父元素之外。

    p>更改源代码并将父元素移动到父元素之外。


  3. 使用 position:fixed 在内部元素。


  4. 删除

    code> position:relative; 从父元素或给父元素 position:static



I'm trying to expand this div across with width of the browser. I've read from here that you can use {position:absolute; left: 0; right:0;} to achieve that as in the jsfiddle here: http://jsfiddle.net/bJbgJ/3/

But the problem is that my current #container has a {position:relative;} property, and hence if I apply {position:absolute} to the child div, it would only refer to #container. Is there a way to still extend my child dive beyond the #container?

解决方案

I can think of five ways to potentially accomplish your goal:

  1. Use negative margins on the inner element to move it outside of the parent

  2. Use Javascript to move the inner element outside of the parent.

  3. Change the source code and move the inner element outside of the parent.

  4. Use position: fixed on the inner element. This will allow the inner element to break out but has the down side that the element will be fixed at the given position (never moving).

  5. Remove the position: relative; from the parent element or give the parent element a position: static

这篇关于扩展超出容器div的子div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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