Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
901 views
in Technique[技术] by (71.8m points)

css - Extend child div beyond container div

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 div beyond the #container?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...