页面在每个浏览器中显示不同,我不知道为什么
[英] Page appears different in each browser, I can't figure out why
本文介绍了页面在每个浏览器中显示不同,我不知道为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我试图在点击链接时关闭我的导航栏.单击时的链接被定向到一个部分而不是一个新页面.导航栏在大屏幕上时我希望它仍然显示但是当它在小屏幕上时我希望汉堡菜单会在例如按下 nextevent 链接时自动关闭有什么想法吗?
<预><代码><身体><导航><header class="header d-flex align-items-center container-fluid"><div class="row align-items-center flex-grow-1"><div class="col-auto"><div class="logo"><h4>托马斯<br>venutu
<ul class="nav-links"><li><a href="#section2">首页</a><li><a href="#section2">NextEvent</a><li><a href="index">音乐</a><li><a href="index">关于</a><li><a href="index">预订</a><div class="汉堡"><div class="line2"></div><div class="line1"></div><div class="line3"></div>
</标题></nav>
<预><代码>#html{滚动行为:平滑;}#额外空间{-webkit-box-sizing: 边框框;-moz-box-sizing: 边框框;box-sizing: 边框框;}#section2 {颜色:#fff;文本阴影:0 0 0.5px rgba(255, 255, 255, 0.25);文本对齐:居中;填充:5em 0 5em 0;边距:0;背景尺寸:125% 自动;}#section2 标题{边距:0 0 2em 0;}*{边距:0px;填充:0px;box-sizing: 边框框;}.header {位置:粘性;顶部:0;最小高度:12vh;背景色:#0c0c0c;}.标识{颜色:白烟;文本转换:大写;字母间距:5px;字体大小:22px;}.导航链接{display:flex!important;justify-content: space-around!important;宽度:100%!重要;}.nav-links li{列表样式:无;}.汉堡div{宽度:25px;高度:5px;背景颜色:whitesmoke;边距:3px;}.汉堡包{显示:无;光标:指针;}.nav-链接{颜色:白烟;文字装饰:无;字母间距:3px;文本转换:大写;字体大小:14px;}@media 屏幕和 (max-width:1024px){.导航链接{显示:inline-flex;justify-content: 空间环绕;宽度:60%;}}@media 屏幕和 (max-width:768px){身体{溢出-x:隐藏;}.nav{位置:固定;顶部:0;}.导航链接{字体大小:1px;位置:固定;右:0px;高度:92vh;顶部:0px;背景色:#0c0c0c;显示:弹性;弹性方向:列;对齐项目:居中;宽度:50%;变换:translateX(100%);过渡:转换 0.5 秒的缓入;}.nav-禁用{变换:translateX(100%);}.nav-links li{;}.汉堡包{显示:块;位置:绝对;顶部:8px;右:16px;}.nav-active{变换:translateX(30%);}#section2 {background-image:url("背景图片venuto4.jpg");背景重复:不重复;高度:100%;宽度:100%;背景颜色:黑色;}#入门{字体大小:12px;}#日{字体大小:14px;}#分钟{字体大小:14px;}#小时{字体大小:12px;}}#section1 {背景图片:网址(background6.png");背景位置:居中;背景重复:不重复;宽度:100vw;高度:100vh;背景附件:固定;背景尺寸:封面;背景颜色:黑色;}#section2 {background-image:url("背景图片venuto4.jpg");背景图像:不重复;高度:100%;宽度:100%;背景颜色:黑色;}#section3 {背景颜色:黑色;高度:100%;}#section4 {背景颜色:whitesmoke;高度:700px;}#section5 {背景颜色:黄色;高度:700px;}.btn-信息{文本转换:大写;字体大小:25px;}.card-img-top{高度:150px;宽度:100px;}h1{颜色:#3b3e42;}
js
const navSlide = () =>{const burger = document.querySelector('.burger');const nav = document.querySelector('.nav-links');const navLinks = document.querySelectorAll('.nav-links li');burger.addEventListener('click', () => {nav.classList.toggle('nav-active');});navLinks.forEach((link, index) => {link.style.animation = `navLinkFade 0.5s 缓动前进 ${index/7}s`;控制台日志(索引/7);nav.classList.toggle('nav-disable');});navLinks.addEventListener('click', () => {nav.classList.toggle('nav-active');});}导航滑动();
需要修复
navLinks.addEventListener('click', () => {nav.classList.toggle('nav-active');});
解决方案
Internet Explorer 可能会跳过媒体查询,以防止遵循常规方法.媒体查询的顺序也很重要.
有多种原因.
尝试删除
@media only screen and (min-width: 600px) {}@media only screen and (min-width: 601px) {}
并且此中的所有代码都移至顶部.
就这样
//所有,包括桌面和移动都在这里html{...//对于较少的移动/智能手机和 ipad 垂直@media only screen and (max-width: 900px) {}//适用于所有移动/智能手机设备@media only screen and (max-width: 600px) {}...
so im trying to make my nav bar close when the link is clicked. the links when clicked are directed to a section not to a new page. the nav bar when its on a large screen i want it to still show but when its on small screen i want that the burger menu will automatically be close when for example the nextevent link is pressed any ideas?
<body>
<nav>
<header class="header d-flex align-items-center container-fluid">
<div class="row align-items-center flex-grow-1">
<div class="col-auto">
<div class="logo">
<h4>thomas<br> venutu</h4>
</div>
</div>
<ul class="nav-links ">
<li><a href="#section2">Home</a> </li>
<li><a href="#section2">NextEvent</a> </li>
<li><a href="index">Music </a> </li>
<li><a href="index">About</a> </li>
<li><a href="index">Boooking</a> </li>
</ul>
<div class="burger">
<div class="line2"></div>
<div class="line1"></div>
<div class="line3"></div>
</div>
</div>
</header>
</nav>
#
html{
scroll-behavior: smooth;
}
#extra space{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#section2 {
color: #fff;
text-shadow: 0 0 0.5px rgba(255, 255, 255, 0.25);
text-align: center;
padding: 5em 0 5em 0;
margin: 0;
background-size: 125% auto;
}
#section2 header {
margin: 0 0 2em 0;
}
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
.header {
position:sticky;
top:0;
min-height: 12vh;
background-color: #0c0c0c;
}
.logo{
color:whitesmoke;
text-transform: uppercase;
letter-spacing: 5px;
font-size:22px;
}
.nav-links{
display:flex!important;
justify-content: space-around!important;
width: 100%!important;
}
.nav-links li{
list-style: none;
}
.burger div{
width: 25px;
height: 5px;
background-color:whitesmoke;
margin:3px;
}
.burger{
display:none;
cursor: pointer;
}
.nav-links a{
color:whitesmoke;
text-decoration: none;
letter-spacing: 3px;
text-transform: uppercase;
font-size: 14px;
}
@media screen and (max-width:1024px){
.nav-links{
display:inline-flex;
justify-content: space-around;
width: 60%;
}
}
@media screen and (max-width:768px){
body{
overflow-x:hidden;
}
.nav{
position: fixed;
top: 0;
}
.nav-links{
font-size: 1px;
position:fixed;
right:0px;
height:92vh;
top: 0px;
background-color: #0c0c0c;
display: flex;
flex-direction: column;
align-items: center;
width: 50%;
transform: translateX(100%);
transition: transform 0.5s ease-in;
}
.nav-disable{
transform: translateX(100%);
}
.nav-links li{
;
}
.burger{
display: block;
position: absolute;
top: 8px;
right: 16px;
}
.nav-active{
transform: translateX(30%);
}
#section2 {
background-image:url("background image venuto4.jpg");
background-repeat:no-repeat;
height: 100%;
width:100% ;
background-color: black;
}
#getting-started{
font-size:12px;
}
#day{
font-size:14px;
}
#minutes{
font-size:14px;
}
#hours{
font-size:12px;
}
}
#section1 {
background-image: url("background6.png");
background-position: center center;
background-repeat: no-repeat;
width: 100vw;
height: 100vh;
background-attachment: fixed;
background-size: cover;
background-color:black;
}
#section2 {
background-image:url("background image venuto4.jpg");
background-image:no-repeat;
height: 100%;
width:100% ;
background-color: black;
}
#section3 {
background-color: black;
height: 100%;
}
#section4 {
background-color: whitesmoke;
height: 700px;
}
#section5 {
background-color: yellow;
height: 700px;
}
.btn-info{
text-transform: uppercase;
font-size: 25px;
}
.card-img-top{
height: 150px;
width: 100px;
}
h1{color: #3b3e42;
}
js
const navSlide = () => {
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');
burger.addEventListener('click', () => {
nav.classList.toggle('nav-active');
});
navLinks.forEach((link, index) => {
link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7}s`;
console.log(index / 7);
nav.classList.toggle('nav-disable');
});
navLinks.addEventListener('click', () => {
nav.classList.toggle('nav-active');
});
}
navSlide();
need fix
navLinks.addEventListener('click', () => {
nav.classList.toggle('nav-active');
});
解决方案
Internet explorer may skip media query so to prevent that follow conventional method. Also order of media query also matters.
There are multiple reason would be there.
Try removing
@media only screen and (min-width: 600px) {
}
@media only screen and (min-width: 601px) {
}
And all code inside this move to top.
So it will be
//for all, including desktop and mobile goes here
html{...
// for less mobile/smartphone and ipad vertical
@media only screen and (max-width: 900px) {
}
// for all mobile/smartphone devices
@media only screen and (max-width: 600px) {
}
...
这篇关于页面在每个浏览器中显示不同,我不知道为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!