Can anyone tell me where I am going wrong in the following code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prax99
    New Member
    • Jan 2015
    • 1

    Can anyone tell me where I am going wrong in the following code?

    Code:
    <!DOCTYPE html>
    <html>
    
    <head>
    
    <style>
    #wrapper {
        width: 2200px;
        transform: translate3d(0, 0, 0);
         transition: transform .5s ease-in-out;
    }
    
    .content {
        float: left;
        width: 550px;
        height: 350px;
        white-space: normal;
        background-repeat: no-repeat;
    }
    #contentContainer {
    ****width: 550px;
    ****height: 350px;
    ****border: 5px black solid;
    ****overflow: hidden;
    }
    #itemOne {
        background-color: #ADFF2F;
        background-image: url("http://www.kirupa.com/images/blueSquare.png");
    }
    #itemTwo {
        background-color: #FF7F50;
        background-image: url("http://www.kirupa.com/images/yellowSquare.png");
    }
    #itemThree {
        background-color: #1E90FF;
        background-image: url("http://www.kirupa.com/images/pinkSquare.png");
    }
    #itemFour {
        background-color: #DC143C;
        background-image: url("http://www.kirupa.com/images/graySquare.png");
    }
    #navLinks {
        text-align: center;
        width: 550px;
    }
        #navLinks ul {
            margin: 0px;
            padding: 0px;
            display: inline-block;
            margin-top: 6px;
        }
            #navLinks ul li {
                float: left;
                text-align: center;
                margin: 10px;
                list-style: none;
                cursor: pointer;
                background-color: #CCCCCC;
                padding: 5px;
                border-radius: 50%;
                border: black 5px solid;
            }
                #navLinks ul li:hover {
                    background-color: #FFFF00;
                }
                #navLinks ul li.active {
                    background-color: #333333;
                    color: #FFFFFF;
                    outline-width: 7px;
                }
                    #navLinks ul li.active:hover {
                        background-color: #484848;
                        color: #FFFFFF;
                    }
    
    </style>
    </head>
    
    <body>
    <div id="contentContainer">
    	<div id="wrapper">
    	    <div id="itemOne" class="content">
     
    	    </div>
    	    <div id="itemTwo" class="content">
     
    	    </div>
    	    <div id="itemThree" class="content">
     
    	    </div>
    	    <div id="itemFour" class="content">
     
    	    </div>
    	</div>
    </div>
    <div id="navLinks">
        <ul>
            <li class="itemLinks" data-pos="0px"></li>
            <li class="itemLinks" data-pos="-550px"></li>
            <li class="itemLinks" data-pos="-1100px"></li>
            <li class="itemLinks" data-pos="-1650px"></li>
        </ul>
    </div>
    
    <script>
    	// just querying the DOM...like a boss!
    var links = document.querySelectorAll(".itemLinks");
    var wrapper = document.querySelector("#wrapper");
     
    // the activeLink provides a pointer to the currently displayed item
    var activeLink = 0;
     
    // setup the event listeners
    for (var i = 0; i < links.length; i++) {
        var link = links[i];
        link.addEventListener('click', setClickedItem, false);
     
        // identify the item for the activeLink
        link.itemID = i;
    }
     
    // set first item as active
    links[activeLink].classList.add("active");
     
    function setClickedItem(e) {
        removeActiveLinks();
        resetTimer();
        var clickedLink = e.target;
        activeLink = clickedLink.itemID;
     
        changePosition(clickedLink);
    }
     
    function removeActiveLinks() {
        for (var i = 0; i < links.length; i++) {
            links[i].classList.remove("active");
        }
    }
     
    // Handle changing the slider position as well as ensure
    // the correct link is highlighted as being active
    function changePosition(link) {
        link.classList.add("active");
     
        var position = link.getAttribute("data-pos");
        var translateValue = "translate3d(" + position + ", 0px, 0)";
        wrapper.style[transformProperty] = translateValue;
    }
    var transforms = ["transform",
                "msTransform",
                "webkitTransform",
                "mozTransform",
                "oTransform"];
     
    var transformProperty = getSupportedPropertyName(transforms);
     
    // vendor prefix management
    function getSupportedPropertyName(properties) {
        for (var i = 0; i < properties.length; i++) {
            if (typeof document.body.style[properties[i]] != "undefined") {
                return properties[i];
            }
        }
        return null;
    }
    
    //
    // The code for sliding the content automatically
    //
    var timeoutID;
     
    function startTimer() {
        // wait 2 seconds before calling goInactive
        timeoutID = window.setInterval(goToNextItem, 2000);
    }
    startTimer();
     
    function resetTimer() {
        window.clearInterval(timeoutID);
        startTimer();
    }
     
    function goToNextItem() {
        removeActiveLinks();
     
        if (activeLink < links.length - 1) {
            activeLink++;
        } else {
            activeLink = 0;
        }
     
        var newLink = links[activeLink];
        changePosition(newLink);
    }
    </script>
    </body>
    </html>
    Attached Files
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    line #21 - #24: CSS properties do not contain stars.

    Comment

    • Exequiel
      Contributor
      • Jul 2012
      • 288

      #3
      delete the asterisk in #contentContain er. it must be
      Code:
      #contentContainer {
          width: 550px;
          height: 350px;
          border: 5px black solid;
          overflow: hidden;
      }
      if you want to make your #contentContain er a comment use /* */ example:
      Code:
      #contentContainer {
         /* width: 550px;
          height: 350px;
          border: 5px black solid;
          overflow: hidden;*/
      }

      Comment

      Working...