添加javascript后,CSS转换不会触发

时间:2016-05-05 00:08:04

标签: javascript css css3 css-transitions

我有三张图像使用transform:translate()从屏幕上滑动。变换具有4s转换持续时间,其中两个具有延迟。没有任何脚本标签(或空白脚本标签),过渡工作正常。但是,当我尝试链接外部javascript文件或添加内部javascript时,转换持续时间和延迟都不起作用,并且图像会立即翻译。

有谁知道为什么会这样?

编辑:CodePen - 没有完全复制问题,因为我无法完全删除JS,但它确实表明转换不起作用。

HTML

<html>
  <head>
    <title>Fake Title</title>
    <link href='http://fonts.googleapis.com/css?family=Noto+Sans:400,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width">
    <link rel="icon" href="img/mountains-icon.jpg">
    <meta name="description" content="blah blah blah.">
    <meta charset="utf-8">
  </head>
  <body class="landing">
    <header class="group">
      <a href="index.html"><h1>Title</h1>
        <h2>Description</h2></a>
      <nav>
        <ul>
          <li><a href="">Portfolio</a></li>
          <li><a href="">Resume</a></li>
          <li><a href="">About</a></li>
        </ul>
      </nav>
    </header>
    <div id="mountains" class="transition">
      <img  src="http://www.clipartbest.com/cliparts/aTq/odR/aTqodRXBc.png" id="one">
      <img src="http://www.clipartbest.com/cliparts/aTq/odR/aTqodRXBc.png" id="two">
      <img src="http://www.clipartbest.com/cliparts/aTq/odR/aTqodRXBc.png" id="three">    
    </div>
  </body>

  <script> console.log("Hello World");</script>
</html>

CSS

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: sans-serif;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

* Layout Element Colors
=========================*/

body:not(.landing) {background: #7B8784 url('http://ginanicoletta.com/img/laguna-beach.jpg') no-repeat center; background-size: cover; color: #0B0214;}
a, footer {color: #fff;}
footer, nav a { background: #30321a;}
#contact-info a {background: #636362;}
.sample-image:before, #profile-photo:before {
    background: rgba(99, 99, 98, 0.5);}
#contact p a {color: #0B0214;}


/* GENERAL STYLES
=========================*/

* {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans', sans-serif;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    text-align: center;
    margin: 0 0 74px;
    color: #fcfcf4;

}

li {
    list-style: none;
    text-align: center;
}

a {
    text-decoration: none;
}

img {
    width: 100%;
}


a:active {
    font-weight: bold;
}

.wrapper {
    padding-bottom: 10px;
}

/*********************************************
**********************************************
TRANSITION/TRANSFORM CODE HERE
**********************************************
*********************************************/

/* LANDING
=========================*/

body.landing {
    background: #7B8784 url('http://ginanicoletta.com/img/laguna-beach.jpg') no-repeat center;
    background-size: cover;
}
nav {
    position: absolute;
    bottom: 0px;
    width: 100%;

}

#mountains {
    display: none;
}


/* HEADER
=========================*/

h1 {
    font-size: 2.9em;
    padding: 20px 0;
}

h2 {
    font-size: 1.8em;
    margin: 0 0 10px;
}

h1, h2 {
    /*color: #0B0214;*/
    text-shadow: 1px 1px 1px #000;
}


/* NAVIGATION
=========================*/

nav a {
    background: #30321a;
}

nav ul {
    position: relative;
    padding-top: 10px;
}

nav ul a, #contact-info a {
    display: block;
    padding: 10px 0;
    border-radius: 5px;
    font-size: 1em;
}

nav ul li {
    position: relative;
    width: 95%;
    margin: 10px 2.5%;
}

#contact-info ul li {
    width: 70%;
    margin: 10px 15%;

}


/* FOOTER
=========================*/

footer {
/*  padding: 0 0 20px;
    float: left;
    width: 100%;
    border-radius: 5px 5px 0 0;
    font-size: .9em;
    margin-top: 10px;*/
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 74px;
}

footer p {
    padding: 0 0 10px;
}

footer img {
    width: 20px;
    height: 20px;
    padding: 0 8px;
}

footer li {
    display: inline-block;
    vertical-align: top;
}

.social-icons {
    padding: 10px 0;
}

/* PAGE: WORK SAMPLES
=========================*/

/*.wrapper {
    padding-top: 15px;
}*/

#work-samples li {
    width: 80%;
    margin: 0 auto;
    padding-top: 15px;
}

#work-samples div {
    position: relative;
    width: 100%;
}

#work-samples img {
    border-radius: 5px;
    box-shadow: 1px 1px 5px #000;
}

#work-samples h3 {
    text-shadow: 1px 1px 5px #000;
    position: absolute;
    text-align: center;
    width: 100%;
    top: 40%;
    font-weight: normal;
    font-size: 1.3em;
    z-index: 100;
}

#work-samples p {
    padding-top: 10px;
}

/* PAGE: ABOUT
=========================*/

.badges {
    margin: 0 auto;
}

/*.badges li {
    position: relative;
    float: left;
    width: 100px;
    height: 150px;
    overflow: scroll;
}*/

.badges li {
    position: relative;
    display: inline-block;
    width: 100px;
    vertical-align: top;
}

.badges li img {
    width: 80px;
}

#about img {
    border-radius: 100%;
    width: 60%;
    margin: 0 auto;
    box-shadow: 1px 1px 5px #000;
}

#about p, #contact p {
    margin: 5px 5%;
    text-align: justify;
}

#about {
    margin: 0 0 20px 0;
}


/* PAGE: CONTACT
=========================*/

#contact img {
    width: 25px;
    padding-right: 5px;
}

/*#contact {
    padding: 5px 0 0 ;
}*/

#contact p a {
    font-weight: bold;
}

/* MEDIA QUERY: 500PX
==============================*/

@media screen and (min-width: 500px) {

    body {
        margin: 0 0 77px;
    }

    h1 {
        font-size: 4em;
    }
    h2 {
        font-size: 2.5em;
    }

/*  #work-samples li {
        display: inline-block;
        width: 45%;
        margin: 0 1%;
        vertical-align: top;
    }*/

/*  .sample-image h3 {
        font-size: 1.05em;
        top: 30%;
    }

    .photo-descriptions {
        padding: 0;
        margin: 0;
        margin-right:0;
    }*/

    nav ul li {
        display: inline-block;
        width: 30%;
        margin: 1.3em 1%;
        vertical-align: middle;
    }

    footer {
        height: 77px;
    }

    footer img {
        width: 25px;
        height: 25px;
        padding: 0 10px;
    }

    #contact-info {
        width: 350px;
        float: right;
    }

    #contact-info li {
        display: inline-block;
        margin: 5px 0;
    }

    #about img {
        width: 50%;
        margin: 0 25%;
    }
}

/* MEDIA QUERY: 700PX
==============================*/

@media screen and (min-width: 700px) {
    #work-samples li {
        overflow: hidden;
        vertical-align: middle;
    }
    #work-samples li p:nth-child(2n) {
        float: left;
        width: 48%;
        margin: 0 1%;
    }

    #work-samples li div:nth-child(2n) {
        width: 48%;
        margin: 0 1%;
        float: left;
    }

    #work-samples li p:nth-child(2n+1) {
        float: right;
        width: 48%;
        margin: 0 1%;
    }

    #work-samples li div:nth-child(2n+1) {
        width: 48%;
        float: right;
        margin: 0 1%;
    }

    h1 {
        font-size: 5em;
    }
    h2 {
        font-size: 3em;
    }

    footer img {
        padding: 0 15px;
    }

    .sample-image h3 {
        font-size: 1.3em;
        top: 35%;
    }

    #about img {
        width: 250px;
        float: left;
        margin: 0 5%;
    }

    #about p {
        font-size: 1.2em;
    }

/*  #about {
        margin: 0 0 40px 0;
    }*/
}

/*********************************************
**********************************************
TRANSITION/TRANSFORM CODE HERE
**********************************************
*********************************************/

/* MEDIA QUERY: 800PX
==============================*/

@media screen and (min-width: 800px) and (orientation: landscape) {

    #mountains {
        display: block;
    }

    #mountains img {
        position: fixed;
        bottom: -800px;
        overflow-y: hidden;
        transform: translatey(-800px);
        transition-duration: 4s;
        /*-webkit-transform: translate(0, -3000px);
        -webkit-transition-duration: 4s;
        -ms-transform: translate(0, -3000px);
        -ms-transition-duration: 4s;
        -o-transform: translate(0, -3000px);
        -o-transition-duration: 4s;*/
    }

    #mountains #one {
        opacity: .4;
        width: 66%;
        left: 0;
        z-index: -10;
        transition-delay: 1s;
        -webkit-transition-delay: 1s;
    }
    #mountains #two {
        opacity: .6;
        width: 40%;
        left: 40%;
        z-index: -9;
        transition-delay: 2s;
        -webkit-transition-delay: 2s;
    }
    #mountains #three {
        opacity: .2;
        width: 33%;
        right: 0;
        z-index: -10;

    }
}

/* MEDIA QUERY: 900PX
============================== */

@media screen and (min-width: 900px) {
    body {
        margin: 0 0 92px;
    }

/*  #about {
        margin: 0 0 70px 0;
    }*/
/*
    .wrapper {
        padding-top: 15px;
    }*/

    footer {
        height: 92px;
    }

    footer img {
        width: 35px;
        height: 35px;
        padding: 5px 20px 0;
    }

    footer ul {
        display: block;
        height: 40px;
    }

    footer img:hover {
        width: 45px;
        padding: 5px 15px 0;
    }

    .sample-image h3 {
        font-size: 1.5em;
        top: 35%;
    }

    .sample-image:hover{
        width: 90%;
        margin: 10px 5%;
        font-size: 1.25em;
        font-weight: bold;
    }

    #work-samples li a:hover h3 {
        font-size: 1.5em;
    }

/*  nav {
        height: 42px;
    }*/

    nav ul a:hover {
        font-size: 1.3em;
    }

    nav ul li:hover {
        width: 32%;
        margin: 0;
    }

    #contact-info li:hover {
        width: 75%;
    }

    nav ul a:hover, #contact-info a:hover {
        padding: 15px 0;
    }

    #contact-info a:hover {
        font-size: 1.1em;
    }

    a:hover {
        font-weight: bold;
    }

    .badges li:hover p, 
    .badges li:hover .tooltip {
        display: inline-block;
    }

    .left p {
        left: 70px;
        box-shadow: 3px 3px 5px rgba(0,0,0, .7);
    }

    .right p {
        right: 70px;
        box-shadow: -3px 3px 5px rgba(0,0,0, .7);
    }

    .badges p {
        display: none;
        position: absolute;
        z-index: 100;
        top: 10;
        background: rgba(150,150,150, .7);
        width: 300%;
        overflow: visible;  
    }

    .tooltip {
        display: none;
        position: absolute;
        width: 0; 
        height: 0;
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        top: 10;

    }

    .left .tooltip {
        border-right: 10px solid rgba(150,150,150, .7);
        left: 60px;
        top: 10;
    }
    .right .tooltip {
        border-left: 10px solid rgba(150,150,150, .7);
        right: 60px;
        top: 10;
    }
}

/* MEDIA QUERY: 1000PX
==============================*/

@media screen and (min-width: 1000px) {

    .wrapper {
        max-width: 1000px;
        margin: 0 auto;
    }
}

0 个答案:

没有答案