Slider Panel

mav3n

lvl 9000 IQ
Joined
May 22, 2011
Messages
4,077
Reaction score
702
FP$
330
I'm back 🙂

Alright, in this tutorial, I will show you how to make a slider panel that uses jQuery, CSS, and some HTML. Wanna see the demo? Of course you do, well here it is! http://gctest2010.formyjob.net/slider2-h2.htm

First: Start with the jQuery
Code:
<script type="text/javascript" src="http://graphiccentral.bravehost.com/slider.js"></script>

<script type="text/javascript">
$(document).ready(function(){

   $(".btn-slide").click(function(){
      $("#panel").slideToggle("slow");
      $(this).toggleClass("active"); return false;
   });
   
    
});
</script>

2. Time for some CSS!

Code:
<style type="text/css">
body {
   margin: 0 auto;
   padding: 0;
   width: 570px;
   font: 75%/120% Arial, Helvetica, sans-serif;
}
a:focus {
   outline: none;
}
#panel {
   background: #c3c3c3;
   height: 200px;
   display: none;
}
.slide {
   margin: 0;
   padding: 0;
   border-top: solid 4px #373737;
   background: url(http://img638.imageshack.us/img638/5051/tabwo.png) no-repeat center top;
}
.btn-slide {
   background: url(http://img21.imageshack.us/img21/8233/whitearrown.gif) no-repeat right -50px;
   text-align: center;
   width: 144px;
   height: 31px;
   padding: 10px 10px 0 0;
   margin: 0 auto;
   display: block;
   font: bold 120%/100% Arial, Helvetica, sans-serif;
   color: #fff;
   text-decoration: none;
}
.active {
   background-position: right 12px;
}
</style>

3. Now, for some HTML

Code:
</head>

<body>

<div id="panel">
    <--!Your Content goes here-->
</div>

<p class="slide"><a href="http://www.graphiccentral.org/index.htm" class="btn-slide">Slide Panel</a></p>

That's it!

Tips!!!

~~ If you wanna change the background of the slider, find
Code:
background: #c3c3c3;
in the css and change the hexadecimal value


Adapted from WebArtzForum.com | Rob​
 
The code is a bit messed up. Especially if it's a custom coded HTML page

Code:
</head>

<body>

<div id="panel">
    <--!Your Content goes here-->
</div>

<p class="slide"><a href="http://www.graphiccentral.org/index.htm" class="btn-slide">Slide Panel</a></p>

Would not help anyone due to the </head>

Though good starter code. I also recommend for those who have a web host to make a CSS file and include the file into the HTML page.
 
First of all, it's an alright tutorial however you should make sure you put the correct markup for the page. Just putting </html>, <body> etc etc is bad practice and you should always use the proper HTML markup, if it wasn't needed, we wouldn't have it.

Secondly, this won't work anyway because you only have the jQuery slider file. You need the actual core of jQuery which can be found here;
Code:
http://code.jquery.com/jquery-latest.js

Clean the code up, put the HTML markup on the HTML code and make sure you include the core jQuery file then you'll have a nice little tutorial for show. Although that red part at the top of your post will scare novices away, best not to do that and always encourage people to learn code languages 😉
 
Yeah, I thought the same thing too. I tags arent right in the HTML, but when I used the code as is on my forum, it worked just fine? Which really threw me off. And the reason I put the red text warning people was because if you knew jQuery, you would of had the code to the jQuery....
 
Awesome! i will be able to use this 🙂
 
Back
Top Bottom