2010-09-27 77 views
0

你能强制一个元素,即在一个continer内,超出该容器吗?强制在容器外面的元素

container{ 
width:985px; 
margin:0 auto; 
} 

footer{ 
i need to force this outside of the container 
} 

希望是有道理的。

+0

如果containe r有固定的高度和..是的。否则你将不得不使用JavaScript。 – helle 2010-09-27 20:08:20

回答

2

CSS:

.container{ 
    width:985px; 
    margin:0 auto; 
    position:relative; 
    padding-bottom:130px; /* height of footer + 30px (your own) */ 
    background:yellow; 
} 

.footer{ 
    position:absolute; 
    left:-25px; /* (1045 - 985)/2 */ 
    bottom:0; /* stick to bottom */ 
    width:1045px; height:100px; 
    background:#CCCCCC; 
} 

HTML:

<div class="container"> 
    Container Area 
    <div class="footer"> 
     Footer Area 
    </div> 
</div> 

前瞻:

alt text