下此代碼運行按預期在Chrome:絕對元素導致行爲怪異火狐
請將鼠標懸停在藍色球的動畫:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
width: 100%;
height: 200px;
border: thin solid #6D6;
overflow: hidden;
}
h2 {
position: absolute;
border-radius: 100%;
background-color: blue;
height:100px;
width: 100px;
transition:all 1s ease-out;
margin: auto;
left: 0;
top: 0;
bottom: 0;
right: 0;
}
h2:hover {
height: 300px;
width: 300px;
}
</style>
</head>
<body>
<div class='container'>
<h2></h2>
</div>
</body>
</html>
但中間的球在Firefox中擴展到底部,我必須設置頂部或底部才能使其回到正確的位置。是否有什麼方法可以讓它保持在中間位置,而不像Chrome中那樣分配頂部和底部值?
它的東西,我不想做的,額外的定位。因爲您可以看到chrome將元素保留在中間,而其擴展卻沒有任何額外的設置。也許這是Firefox的默認行爲。 –
@RyVan只是因爲某些事情在Chrome中表現出某種特定的方式,並不意味着這是標準。這個想法是編寫在任何地方都運行相同的代碼。您正在使用Chrome進行開發,並抱怨Firefox顯示的內容有所不同。如果您是第一次使用Firefox開發的,則不會遇到此問題。我的建議仍然存在這是我在很多地方看到的一個很好的做法。這不是黑客。 – Narxx
感謝的人,但我需要知道的是天氣有可能在Firefox中做類似的事情。 –