我的html / CSS模式有以下问题。
我有一个固定的顶部菜单(高度:110像素)。在这个固定的菜单中,我尝试创建一个仅在悬停时显示的购物车。为此,我使用了一个仅在光标悬停时显示的div。
它适用于Firefox和Chrome。名为"hover-content“的div不在流中。但对于Safari来说,它并不像预期的那样工作。div显示在顶部菜单中,而不是在流程之外。


你知道我如何在Safari上解决这个问题吗?
提前感谢您的帮助。
Singertwist
.menu-top-commander {
background-color: #FFFFFF;
height: 100px;
display: flex;
flex-direction: row;
position: fixed;
transition-duration: 0.5s;
box-sizing: border-box;
right: 0;
padding-left: 110px;
align-items: center;
overflow: hidden;
}
.menu-top-commander-texte:first-child {
margin-left: 25px;
padding: 10px 10px 10px 0;
font-size: 25px;
color: #CE3734;
border-right: solid;
border-width: 1px;
}
.menu-top-commander-texte:nth-child(2) {
width: 100%;
}
.menu-top-commander-texte .menu-top-commander-texte-lien {
display: inline-flex;
padding: 10px 10px 10px 10px;
overflow-wrap: break-word;
word-wrap: break-word;
margin: 0;
font-size: 20px;
}
.menu-top-commander-texte p a {
color: #000000;
}
.menu-top-commander-smaller {
background-color: #FFFFFF;
height: 65px;
transition-duration: 0.5s;
}
.menu-top-commander-texte-lien:last-child {
float: right;
padding-right: 50px;
}
#hover-content {
display: none;
position: fixed;
background-color: #f9f9f9;
width: 200px;
min-height: 100px;
max-height: 300px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 12px 16px;
transform: translate(-200px, 50px);
overflow-y: scroll;
perspective: 1000;
}
.menu-top-commander-texte-lien:last-child:hover #hover-content {
display: block;
}
.menu-top-commander-texte-lien:last-child img {
width: 30px;
height: auto;
}
@media only screen and (max-width: 699px) {
.menu-top-commander {
display: flex;
flex-direction: column;
padding-left: 0px;
position: relative;
height: auto;
justify-content: center;
}
.menu-top-commander-texte:first-child {
margin-left: 0;
width: 100%;
border-style: none;
}
.menu-top-commander-texte {
display: flex;
flex-wrap: wrap;
width: 100%;
justify-content: center;
}
.menu-top-commander-texte p {
font-size: 18px;
}
.menu-top-commander-texte-lien:last-child {
float: right;
}
}<div class="menu-top-commander">
<div class="menu-top-commander-texte">Menu</div>
<div class="menu-top-commander-texte">
<div class="menu-top-commander-texte-lien">
<p><a href="">Plats</a></p>
</div>
<div class="menu-top-commander-texte-lien">
<p><a href="">A-Côtés</a></p>
</div>
<div class="menu-top-commander-texte-lien">
<p><a href="">Boissons</a></p>
</div>
<div class="menu-top-commander-texte-lien">
<p><a href="">Desserts</a></p>
</div>
<div class="menu-top-commander-texte-lien">
<p>
<a href=""><img src="img/icones/shopping-cart.png" alt="shopping cart"></a>
</p>
<div id="hover-content">
Content.
</div>
</div>
</div>
</div>
发布于 2017-09-24 17:50:00
谢谢你的帮助。所以,我找到了一个解决方案。实际上,Safari的问题是嵌套div的两个固定位置。第一个div (父div)具有固定位置,子div (在悬停时显示)也具有固定位置。
对于第一个div (父div),我尝试了一个粘性位置,而对于第二个div (子div),我使用了一个固定的位置。
它适用于Chrome、Firefox和Safari。
谢谢你的帮助,
辛格威斯特
https://stackoverflow.com/questions/46382553
复制相似问题