English 中文(简体)
从相对处于位置的父(母)亲中释放绝对处于位置的儿童
原标题:Release absolutely positioned child from relative positioned parent
  • 时间:2012-05-24 10:08:27
  •  标签:
  • jquery
  • css

情况是这样的...

HTML :

   <div id="cw">
        <div id="c"></div>        
   </div>
   <a href="#">click me</a>

CSS :

#cw {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 100px 200px 0 200px;     
    padding: 10px;
}

#c {
    background: blue;
    display: block;
    height: 200px;
    width: 200px;    
}

-gt;"http://jsfiddle.net/F6FF2/4/" rel="no follow" >http://jsfiddle.net/F6FF2/4/

现在,我想实现的是这个。 如果点击“ 点击我” 链接, 内部容器< codec 应该从页面上提供的窗口位置扩大到窗口的全部范围 。

我想这只能通过指定 < code> position: 绝对 来达到。 但我遇到了一个问题, 即它的父母是相对的。

因此,我至今所想的就是克隆 < codec ,将其从DOM中删除,并在模拟扩展之前将克隆附在 < code>body 上,然后才能产生预期的结果。然而,问题是,如果 包含例如谷歌地图,则该地图必须在克隆事件发生后重新验证(而不仅仅是刷新瓷砖)。

除了这种解决办法似乎相当混乱之外,还必须有一个更好、更干净的解决办法。

有什么想法吗?

最佳回答

您在此覆盖内容( 地图) :

c.text(c_width+" > "+c_height+" > "+c_left+" > "+c_top);

不要覆盖内容, 也不要使用克隆人( 移动原版), 在定义动画时触发更改大小的活动 :

http://jsfiddle.net/F6FF2/10/" rel="nown" >http://jsfiddle.net/F6FF2/10/

问题回答

您是否尝试过将div移到身体元件上, 而不是克隆它?

$("body").append($("#c"))

完成后,您可以将其移回原处:

$("#cw").append($("#c"))




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签