2012-02-01 82 views
0

我在使用絕對div中的負位置(例如top:-20px)時遇到問題,並向父級div添加overflow auto。本文轉至隱藏在所有瀏覽器中。我想讓它可見。在我的應用程序結構中,不可能刪除overflow:auto;。喲有任何想法,如何使其可見?只要複製這些代碼,您就會得到更好的主意。負位置與溢出自動使元素隱藏

<!DOCTYPE html> 
<head> 
<title>Untitled Document</title> 
<style> 
body{ 
    margin:50px; 
} 
.Relative{ 
    width:200px; 
    height:200px; 
    position:relative; 
    overflow:auto; 
    background-color:#CCCCCC; 
    z-index:1; 
} 
.Abs{ 
    position:absolute; 
    top:-20px; 
    right:0; 
    width:100px; 
    height:100px; 
    border:solid 1px; 
    background-color:#99CCCC; 
    z-index:99999999 !important; 
} 
.RemoveOverFlow{ 
    overflow:inherit; 
} 
</style> 
</head> 

<body> 

<div class="Relative RemoveOverFlow"> 
    <div class="Abs">This is a test text in absolute div</div> 
Remove <br /> 
overflow <br /> 
from the <br /> 
relative div 
</div> 

<br /> 
<br /> 

<div class="Relative"> 
    <div class="Abs">This is a test text in absolute div</div> 
Add <br /> 
overflow:auto <br /> 
into <br /> 
relative div  
</div> 
</body> 
</html> 

回答

1

嘗試.Relative類改變overflow: autooverflow:visible

例小提琴:http://jsfiddle.net/Wpcnx/

+0

謝謝..但它不可能刪除溢出:自動。我們可以不刪除它嗎? – Avkash 2012-02-01 10:35:24

+0

稍後定義.Relative類和overflow的另一個規則:visible:它將覆蓋第一個規則 – fcalderan 2012-02-01 10:41:49