[英]IE11 position fixed has wrong size
為什么IE11為固定位置的元素設置了錯誤的大小? 當他的父母有一個相對位置,該位置的大小精確定義且帶有邊界半徑和隱藏的溢出時,則固定元素將采用其父母的尺寸,而不是其自己的尺寸。
例:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-CH" lang="de-CH">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Fixed Test</title>
<style>
div {
position: relative;
overflow: hidden;
min-height: 100px;
width: 200px;
border-radius: 5px;
background-color: green;
}
.fixed {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 1000;
background-color: red;
}
</style>
</head>
<body>
<div><span onclick="this.className='fixed'">click me</span></div>
</body>
</html>
當我將此行為與Chrome進行比較時,此處的關鍵似乎是overflow: hidden
。 規范中可能對此有一些具體說明,但我認為IE至少在部分方面是正確的。 當我嘗試時,固定跨度占據了整個視口的寬度和高度,但是被其包含div的溢出屬性所掩蓋-移除該寬度會使整個屏幕變為紅色。
但是,它仍然將左上角變成一條直線,這似乎是不正確的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.