CSS无法在手机浏览器上运行

时间:2019-06-22 11:53:15

标签: html css mobile

我试图建立一个网站,并且在计算机上可以正常工作,但是当我在手机ID上打开该网站时,该CSS不会运行。


未运行的css是带有三角形的那个,该三角形将转移到背景中


我已经尝试过搜索它,但是对于多个案例,似乎有不同的答案

您可以在运行网站的同时访问andrei-marin.com

*编辑:它运行的很好,只有谷歌浏览器和Firefox,但无法在笔记本电脑上的野生动物园工作! 这是HTML:

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Reveal content animation (and menu)</title>
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">

  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat:400,700'>

      <link rel="stylesheet" href="./style2.css">


</head>

<body>

  <header>
  <div class="triangle left"><div class="typewriter"><h1>Andrei Marin</h1></div></div>
  <div class="triangle right"><div class="typewriter"><h1>Andrei Marin</h1></div></div>
  <button></button>
</header>

<nav>
  <ul>
    <li>Home</li>
    <li>About</li>
    <li>Projects</li>
    <li>Contact</li>
  </ul>
  <div id="nav-close"><i class="fas fa-times"></i></div>
</nav>

<content>
  <section>Home</section>
  <section>About</section>
  <section>Projects</section>
  <section>Contact</section>
</content>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>



    <script  src="./script.js"></script>




</body>

</html>

这是CSS:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 300vh;
  background-image: linear-gradient(to top, #cdcdcd 0%, #818181 100%);
}

header {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
header h1, header button {
  position: relative;
  z-index: 10;
}

header button {
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  bottom: 100px;
  left: calc(50% - 60px);
  width: 120px;
  height: 50px;
  border: 0;
  box-shadow: 2px 1px 20px 0 rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  font-size: 1em;
  color: #09203f;
  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1), transform 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955), box-shadow 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
  overflow: hidden;
}
header button:hover {
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.5);
}
header button:focus {
  outline: 0;
}
header button:before, header button:after {
  font-family: "Font Awesome 5 Free";
  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
  top: 17px;
  position: absolute;
}
header button:before {
  content: "\f067";
  opacity: 1;
  left: 53px;
}
header button:after {
  content: "\f0c9";
  opacity: 0;
  left: 0;
}
header .triangle {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, #09203f 0%, #537895 100%);
  background: url('bg.jpg');
  height: 100%;

  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  margin-bottom: 40px;
  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
header .triangle.left {
  clip-path: polygon(0 0, 0% 100%, 100% 100%);
}
header .triangle.right {
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
header.open .triangle.left {
  clip-path: polygon(0 0, 0 100%, 0 100%);
}
header.open .triangle.right {
  clip-path: polygon(100% 0, 100% 0, 100% 100%);
}
header.open button {
  left: 40px;
  bottom: 40px;
  width: 50px;
  border-radius: 50%;
}
header.open button:before {
  opacity: 0;
  left: 100%;
}
header.open button:after {
  opacity: 1;
  left: 18px;
}
header.open button.menu {
  width: 100%;
  height: 100%;
  bottom: 0;
  left: 0;
  border-radius: 0;
}
header.open button.menu:after {
  left: -100%;
}

content section {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1em;
  letter-spacing: 2pt;
  color: #fff;
}

nav {
  text-align: center;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  display: none;
}
nav ul {
  list-style: none;
}
nav ul li {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 2;
  letter-spacing: 1pt;
  font-size: 2em;
  color: #09203f;
  animation: fadeDown .5s forwards;
  opacity: 0;
  cursor: pointer;
  transform: translateY(-20px);
  transition: all 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
nav ul li:hover {
  text-shadow: 2px 1px 40px rgba(0, 0, 0, 0.5);
  opacity: .8;
}
nav ul li:nth-child(1) {
  animation-delay: 0.8s;
}
nav ul li:nth-child(2) {
  animation-delay: 0.9s;
}
nav ul li:nth-child(3) {
  animation-delay: 1s;
}
nav ul li:nth-child(4) {
  animation-delay: 1.2s;
}
nav #nav-close {

  position: fixed;
  top: 40px;
  right: 40px;
  font-size: 1.5em;
  cursor: pointer;
  animation: fadeDown .5s forwards;
  animation-delay: 1.1s;
  opacity: 0;
  color: #09203f;
  transform: translateY(-20px);
}
@keyframes fadeDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
  color: #fff;
  font-family: Arial;
  overflow: hidden; /* Ensures the content is not revealed until the animation */
  border-right: .15em solid orange; /* The typwriter cursor */
  white-space: nowrap; /* Keeps the content on a single line */
  margin: 0 auto; /* Gives that scrolling effect as the typing happens */
  letter-spacing: .15em; /* Adjust as needed */
  animation:
    typing 3.5s steps(30, end),
    blink-caret .5s step-end infinite;
}

/* The typing effect */
@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

/* The typewriter cursor effect */
@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: white }
}

这是JS:

// function to open/close nav
function toggleNav(){
  // if nav is open, close it
  if($("nav").is(":visible")){
    $("nav").fadeOut();
    $("button").removeClass("menu");
  }
  // if nav is closed, open it
  else{
    $("button").addClass("menu");
    $("nav").fadeIn().css('display', 'flex');
  }
}

// when clicking + or ☰ button
$("button").click(function(){
  // when clicking ☰ button, open nav
  if($("header").hasClass("open")){
    toggleNav();
  }
  // when clicking + button, open header
  else{
    $("header").addClass("open");
  }
});

// close nav
$("#nav-close").click(function(){
  toggleNav();
});

// scroll to sections
$("nav li").click(function(){
  // get index of clicked li and select according section
  var index = $(this).index();
  var target = $("content section").eq(index);

  toggleNav();

  $('html,body').delay(300).animate({
    scrollTop: target.offset().top
  }, 500);
});

1 个答案:

答案 0 :(得分:0)

尝试清除手机上浏览器的数据。它工作正常,可能是浏览器未重新加载CSS的问题。您还可以临时更改样式表URL,以便浏览器被迫再次获取它。

enter image description here

似乎更像是您设备的问题。同样在Chrome浏览器中,尝试在网络设置中尝试F12disable cache,然后尝试使用移动设备预设进行查看。