473,467 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

1 New Member
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.  
  6. <style>
  7. #wrapper {
  8.     width: 2200px;
  9.     transform: translate3d(0, 0, 0);
  10.      transition: transform .5s ease-in-out;
  11. }
  12.  
  13. .content {
  14.     float: left;
  15.     width: 550px;
  16.     height: 350px;
  17.     white-space: normal;
  18.     background-repeat: no-repeat;
  19. }
  20. #contentContainer {
  21. ****width: 550px;
  22. ****height: 350px;
  23. ****border: 5px black solid;
  24. ****overflow: hidden;
  25. }
  26. #itemOne {
  27.     background-color: #ADFF2F;
  28.     background-image: url("http://www.kirupa.com/images/blueSquare.png");
  29. }
  30. #itemTwo {
  31.     background-color: #FF7F50;
  32.     background-image: url("http://www.kirupa.com/images/yellowSquare.png");
  33. }
  34. #itemThree {
  35.     background-color: #1E90FF;
  36.     background-image: url("http://www.kirupa.com/images/pinkSquare.png");
  37. }
  38. #itemFour {
  39.     background-color: #DC143C;
  40.     background-image: url("http://www.kirupa.com/images/graySquare.png");
  41. }
  42. #navLinks {
  43.     text-align: center;
  44.     width: 550px;
  45. }
  46.     #navLinks ul {
  47.         margin: 0px;
  48.         padding: 0px;
  49.         display: inline-block;
  50.         margin-top: 6px;
  51.     }
  52.         #navLinks ul li {
  53.             float: left;
  54.             text-align: center;
  55.             margin: 10px;
  56.             list-style: none;
  57.             cursor: pointer;
  58.             background-color: #CCCCCC;
  59.             padding: 5px;
  60.             border-radius: 50%;
  61.             border: black 5px solid;
  62.         }
  63.             #navLinks ul li:hover {
  64.                 background-color: #FFFF00;
  65.             }
  66.             #navLinks ul li.active {
  67.                 background-color: #333333;
  68.                 color: #FFFFFF;
  69.                 outline-width: 7px;
  70.             }
  71.                 #navLinks ul li.active:hover {
  72.                     background-color: #484848;
  73.                     color: #FFFFFF;
  74.                 }
  75.  
  76. </style>
  77. </head>
  78.  
  79. <body>
  80. <div id="contentContainer">
  81.     <div id="wrapper">
  82.         <div id="itemOne" class="content">
  83.  
  84.         </div>
  85.         <div id="itemTwo" class="content">
  86.  
  87.         </div>
  88.         <div id="itemThree" class="content">
  89.  
  90.         </div>
  91.         <div id="itemFour" class="content">
  92.  
  93.         </div>
  94.     </div>
  95. </div>
  96. <div id="navLinks">
  97.     <ul>
  98.         <li class="itemLinks" data-pos="0px"></li>
  99.         <li class="itemLinks" data-pos="-550px"></li>
  100.         <li class="itemLinks" data-pos="-1100px"></li>
  101.         <li class="itemLinks" data-pos="-1650px"></li>
  102.     </ul>
  103. </div>
  104.  
  105. <script>
  106.     // just querying the DOM...like a boss!
  107. var links = document.querySelectorAll(".itemLinks");
  108. var wrapper = document.querySelector("#wrapper");
  109.  
  110. // the activeLink provides a pointer to the currently displayed item
  111. var activeLink = 0;
  112.  
  113. // setup the event listeners
  114. for (var i = 0; i < links.length; i++) {
  115.     var link = links[i];
  116.     link.addEventListener('click', setClickedItem, false);
  117.  
  118.     // identify the item for the activeLink
  119.     link.itemID = i;
  120. }
  121.  
  122. // set first item as active
  123. links[activeLink].classList.add("active");
  124.  
  125. function setClickedItem(e) {
  126.     removeActiveLinks();
  127.     resetTimer();
  128.     var clickedLink = e.target;
  129.     activeLink = clickedLink.itemID;
  130.  
  131.     changePosition(clickedLink);
  132. }
  133.  
  134. function removeActiveLinks() {
  135.     for (var i = 0; i < links.length; i++) {
  136.         links[i].classList.remove("active");
  137.     }
  138. }
  139.  
  140. // Handle changing the slider position as well as ensure
  141. // the correct link is highlighted as being active
  142. function changePosition(link) {
  143.     link.classList.add("active");
  144.  
  145.     var position = link.getAttribute("data-pos");
  146.     var translateValue = "translate3d(" + position + ", 0px, 0)";
  147.     wrapper.style[transformProperty] = translateValue;
  148. }
  149. var transforms = ["transform",
  150.             "msTransform",
  151.             "webkitTransform",
  152.             "mozTransform",
  153.             "oTransform"];
  154.  
  155. var transformProperty = getSupportedPropertyName(transforms);
  156.  
  157. // vendor prefix management
  158. function getSupportedPropertyName(properties) {
  159.     for (var i = 0; i < properties.length; i++) {
  160.         if (typeof document.body.style[properties[i]] != "undefined") {
  161.             return properties[i];
  162.         }
  163.     }
  164.     return null;
  165. }
  166.  
  167. //
  168. // The code for sliding the content automatically
  169. //
  170. var timeoutID;
  171.  
  172. function startTimer() {
  173.     // wait 2 seconds before calling goInactive
  174.     timeoutID = window.setInterval(goToNextItem, 2000);
  175. }
  176. startTimer();
  177.  
  178. function resetTimer() {
  179.     window.clearInterval(timeoutID);
  180.     startTimer();
  181. }
  182.  
  183. function goToNextItem() {
  184.     removeActiveLinks();
  185.  
  186.     if (activeLink < links.length - 1) {
  187.         activeLink++;
  188.     } else {
  189.         activeLink = 0;
  190.     }
  191.  
  192.     var newLink = links[activeLink];
  193.     changePosition(newLink);
  194. }
  195. </script>
  196. </body>
  197. </html>
  198.  
Attached Files
File Type: txt Slider.txt (1.1 KB, 177 views)
Jan 14 '15 #1
2 1238
Dormilich
8,658 Recognized Expert Moderator Expert
line #21 - #24: CSS properties do not contain stars.
Jan 14 '15 #2
Exequiel
288 Contributor
delete the asterisk in #contentContainer. it must be
Expand|Select|Wrap|Line Numbers
  1. #contentContainer {
  2.     width: 550px;
  3.     height: 350px;
  4.     border: 5px black solid;
  5.     overflow: hidden;
  6. }
  7.  
if you want to make your #contentContainer a comment use /* */ example:
Expand|Select|Wrap|Line Numbers
  1. #contentContainer {
  2.    /* width: 550px;
  3.     height: 350px;
  4.     border: 5px black solid;
  5.     overflow: hidden;*/
  6. }
  7.  
Jan 14 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Fang | last post by:
Hi, I'm new to PHP. I followed an example on the book and wanted to pass a variable from one html page to a php page, but it always tells me the passed variable is undefined. I've checked the...
1
by: Vinodh | last post by:
Hi, I created an ASP.NET application in VB.NET. I put one text box (Textbox1) and a button (button1) to the web form (webform1). Then I clicked on the button and add the following code. ...
3
by: Materialised | last post by:
I am having some issues with the following code, basically what I am trying to do, is familierise myself with compiler warnings, when I try to access a private or protected class function. Here is...
2
by: Tony | last post by:
I found similar code for encoding/decoding strings in VB which works fine. However I wanted to use it in a C# projected and can't get it to work. When it executes the TransformFinalBlock() call at...
7
by: Mike Barnard | last post by:
It's a simple test... VERY SIMPLE. But... In an external stlyesheet some attributes don't show. With the same styles cut and pasted to the test internally it works as expected. Anyone tell...
7
by: Jason Kid | last post by:
Hi, Please tell me what's wrong with the following code. private bool CheckIt( int iArg, bool fArg) { bool fIsGood = false;
15
by: E-Dot | last post by:
I am trying to write a program which asks the user to enter a number in the interval , the program then gives the natural logarithm of that number, using the series for log(x+1)... Here is what...
14
by: ramadeviirrigireddy | last post by:
Hi All, I have the following code for form and servlet. when the form is submitted the servlet will print the values passed by the form. i'm not getting the servlet o/p when i submit the...
12
by: kang jia | last post by:
hi currently i am doing this car booking website. i would like to only update our inventory one day before customer's start booking time, thus before that, i am still able to rent to other...
3
by: adamnorsworthy | last post by:
I have a query called 'Query1' and it uses the following SQL: SELECT DISTINCT nps.Agent , nps. , (Select Count(*) from Where < .) AS Rank FROM
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.