鉴于以下HTML和CSS,myLinks div在1025px以下的屏幕上隐藏,并在1025px以上的屏幕上显示为flexbox。 div仍然隐藏在Safari中。
#myLinks {
display: none;
}
.menu-link {
padding-top: 0.5em;
}
@media only screen and (min-width: 1025px) {
#myLinks {
background-color: transparent;
display: -webkit-flex;
display: flex;
flex-direction: column;
position: fixed;
width: 300px;
top: 10%;
right: 0;
height: 85vh;
max-height: 85%;
border-radius: 10px;
}
}
<div id="myLinks" class="menu-link"></div>
真正奇怪的是,我只是注意到元素在页面上,但是没有被渲染。我可以单击它们,但看不到它们。将z-index更改为999不能解决问题
编辑:这是一个完整的示例,我认为没有任何孩子会导致#myLinks隐藏,因为从#myLinks中删除的.menu-card元素会显示并正常工作,但是这里的某些内容可能不会在myLinks中玩得不好...
全页运行
#myLinks {
display: none;
}
.menu-link {
padding-top: 0.5em;
}
.menu-card {
display: block;
text-align: center;
padding-bottom: 0;
margin-left: 5%;
margin-right: 5%;
margin-bottom: 4%;
}
.card-text {
text-align: center;
font-size: 0.75em;
padding: 0;
margin: 0;
line-height: 1;
}
/*Style navigation menu images*/
.menu-icon {
display: block;
max-width: 15%;
vertical-align: middle;
margin: auto;
}
/* Style navigation menu links */
#myLinks a {
display: block;
color: white;
font-size: 1.4rem;
text-shadow: 2px 2px black;
text-decoration: none;
text-align: center;
margin-top: 0;
padding: 14px 16px;
padding-top: 0;
}
@media only screen and (min-width: 1025px) {
#myLinks {
background-color: transparent;
display: -webkit-flex;
display: flex;
flex-direction: column;
position: fixed;
width: 300px;
top: 10%;
right: 0;
height: 85vh;
max-height: 85%;
border-radius: 10px;
}
.menu-card a {
position: relative;
width: 100%;
}
.menu-icon {
position: absolute;
z-index: 1;
right: 20%;
max-height: 55%;
border-radius: 50%;
background-color: rgb(148, 181, 201);
background-color: rgba(148, 181, 201, 0.9);
transition: all 0.8s;
max-width: 100%;
}
.card-text {
display: -webkit-flex;
display: flex;
align-items: center;
width: 0;
top: 6%;
height: 100%;
max-height: 0;
text-align: left;
font-size: 125%;
opacity: 0;
color: #5DCA31;
background-color: transparent;
text-shadow: 2px 2px black;
margin: 0;
border-color: rgb(148, 181, 201);
border-color: rgba(148, 181, 201, 0.9);
border-style: solid;
border-radius: 90px;
transition: all 0.8s;
padding-right: 0;
}
.menu-card:hover {
background-color: transparent;
opacity: 1;
transition: all 0.8s;
}
.menu-card:hover .menu-icon {
right: 5%;
}
.menu-card:hover .card-text {
opacity: 1;
padding-left: 10%;
max-height: 65%;
width: 100%;
border-width: 8px;
box-sizing: border-box;
background-color: rgb(148, 181, 201);
background-color: rgba(148, 181, 201, 0.9);
padding-right: 100px;
padding-top: 10px;
padding-bottom: 10px;
transition: background-color 0.8s, border-width 0.8s, max-width 0.8s;
}
}
<div id="myLinks" class="menu-link">
<div class="menu-card">
<a href="#">
<img class="menu-icon" src="https://nuclearterrortoday.org/img/home.jpg">
<p class="card-text" id="home">Home</p>
</a>
</div>
</div>
答案 0 :(得分:0)
尝试使用
@media screen and (min-width: 1025px) {
#myLinks {
/* all the styles */
}
}
或者只是
@media (min-width: 1025px) {
#myLinks {
/* all the styles */
}
}
关键字“仅”对较旧的用户代理隐藏样式表。 希望这会有所帮助!