gpt4 book ai didi

Css 媒体查询在 chrome 和 safari 中无法正常工作

转载 作者:行者123 更新时间:2023-11-27 22:54:49 24 4
gpt4 key购买 nike

当页面调整大小或屏幕尺寸低于 500 像素时,我试图让我的水平菜单转换为垂直菜单,但在进行更改后我意识到我的菜单仅在边缘而不是在 safari 或 chrome 中表现得像这样。在 safari 中,菜单无论大小都是垂直显示的,而在 chrome 菜单中,无论大小是水平显示的。我怎样才能让它表现得像在 ie 和 edge 中一样?

下面是我的索引 html 和 css 文件:

/* CSS Document */

body {
font-family: 'Happy Monkey', cursive;
}

.container {
position: relative;
top: 5px;
}

.top {
position: relative;
}

.banner-home {
position: absolute;
top: 0px;
height: 237px;
width: 300px;
background-image: url("../images/faruk-yeni2.png");
background-position: center;
background-size: cover;
padding-bottom: 0px;
}

.baslik-altcizgi {
position: absolute;
top: 235px;
padding-top: 0px;
width: 100%;
height: 20px;
background-color: #111111;
}

.baslik-yazi {
position: absolute;
top: 255px;
text-align: left;
font-size: 2em;
height: 30px
}

main {
position: absolute;
top: 550px;
}

nav ul li a {
text-decoration: none;
color: #F2B544;
background-color: #2C0E40;
display: block;
text-align: center;
padding: 10px 0 10px 0;
margin-bottom: 5px
}

nav ul li a:hover {
background-color: #0D0D0D;
color: #FFFFFF
}

nav ul {
position: relative;
top: 300px;
list-style: none;
padding-left: 0;
}

.image-one {
text-align: center;
padding: 0 20px;
}

.image-two {
text-align: center;
padding: 0 20px;
}

.image-three {
text-align: center;
padding: 0 20px;
}

.art-one-home-img {
width: 100%;
height: 650px;
}

.art-two-home-img {
width: 100%;
height: 650px;
}

.art-three-home-img {
width: 100%;
height: 650px;
}

@media screen and (min-width:500px) {
nav ul {
display: flex;
}
nav ul li {
flex: 1;
margin: 0px;
}
.feature-images {
display: flex;
}
}
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ömer Faruk Durusoy</title>
<link rel="stylesheet" href="css/homepage.css">
<link href="https://fonts.googleapis.com/css?family=Happy+Monkey&display=swap" rel="stylesheet">
</head>

<body>
<div class="container">
<header>
<div class="top">
<div class="banner-home"></div>
<div class="baslik-altcizgi"></div>
<div class="baslik-yazi">
My name
</div>
</div>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="videos.html">Videos</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section class="feature-images">
<div class="image-one">
<img src="images/javascript.png" alt="Javascript">
<p>Lorem ipsum </p>
</div>
<div class="image-two">
<img src="images/html5.png" alt="html5">
<p>Lorem ipsum </p>
</div>
<div class="image-three">
<img src="images/java.png" alt="Java">
<p>Lorem ipsum </p>
</div>
</section>
<article class="art-one-home">
<div class="art-one-home-img"></div>
<h2>This is the article one</h2>
<p>Lorem ipsum</p>
</article>
<article class="art-two-home">
<div class="art-two-home-img"></div>
<h2>This is the article one</h2>
<p>Lorem ipsum </p>
</article>
<article class="art-three-home">
<div class="art-three-home-img"></div>
<h2>This is the article one</h2>
<p>Lorem ipsum</p>
</article>
</main>
<footer>

</footer>
</div>

</body>

</html>

最佳答案

试试这个方法。首先向元素声明类或 css 属性,然后它会根据屏幕大小进行更改。

      nav ul {
display: flex;
}
nav ul li {
flex: 1;
margin: 0px;
}
.feature-images {
display: flex;
}

@media screen and (min-width:500px) {
nav ul {
display: flex;
}
nav ul li {
flex: 1;
margin: 0px;
}
.feature-images {
display: flex;
}
}

关于Css 媒体查询在 chrome 和 safari 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59302460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com