2011-10-20 27 views
0

使用嵌套div我想剪切頂部並左側居中內部div。剪切包含在另一個div內的div的頂部和左側

<div> 
<div style="position: relative; top: -160px; left: 10px; width: 400px; height: 400px; overflow: hidden;"> 
<!-- div> 
<div style="width: 686px; height: 600px; overflow: hidden;" --> 
<IFRAME SRC="http://www.aol.com/" FRAMEBORDER="0" BORDER="0" ID="slpane" width="900px" height="900px"></iframe> 
</div> 
</div> 

有一個負的頂部和左側似乎把內部的div放在包含div的頂部和左側。如何在裁剪頂部和左側時保持div嵌套?

回答

1

添加overflow:hidden到的元素的父元素具有負top

小提琴:http://jsfiddle.net/VZ3gt/

<div style="overflow:hidden;"> 
<div style="position: relative; top: -160px; left: 10px; width: 400px; height: 400px; overflow: hidden;"> 
<!-- div> 
<div style="width: 686px; height: 600px; overflow: hidden;" --> 
<IFRAME SRC="http://www.aol.com/" FRAMEBORDER="0" BORDER="0" ID="slpane" width="900px" height="900px"></iframe> 
</div> 
</div> 
1

更改父元素(具有負填充)上的CSS包括

overflow: hidden; 
+0

感謝您的回答。 – user823527

相關問題