hej,
Har problemer med at få en Horizontal menu lavet om til vertical menu.
Når jeg laver alle "span" tags om til "a" og redigerer
- $(".container .TabMenu span").click(function(){
om til:
- $(".container .sidenav a").click(function(){
så den skulle virke på når man trykkede på linket i den nye menu, men så slider menuen bare hen til en tom siden i stedet
-Souce-nye Vertical menu:
- <ul class="sidenav">
- <li>
- <a href="#">1
- <span>Blandit turpis patria euismod at iaceo appellatio, demoveo esse. Tation utrum utrum abigo demoveo immitto aliquam sino aliquip. </span>
- </a>
- </li>
- <li>
- <a href="#">2
- <span>Blandit turpis patria euismod at iaceo appellatio, demoveo esse. Tation utrum utrum abigo demoveo immitto aliquam sino aliquip. </span>
- </a>
- </li>
- <li>
- <a href="#">3
- <span>Blandit turpis patria euismod at iaceo appellatio, demoveo esse. Tation utrum utrum abigo demoveo immitto aliquam sino aliquip. </span>
- </a>
- </li>
- </ul>
javascript:
- <script type="text/javascript">
-
- $(document).ready(function(){
- //Initialize
- //Set the selector in the first tab
- $(".container .TabMenu span:first").addClass("selector");
-
-
- //Basic hover action
- $(".container .TabMenu span").mouseover(function(){
- $(this).addClass("hovering");
- });
- $(".container .TabMenu span").mouseout(function(){
- $(this).removeClass("hovering");
- });
-
- //Add click action to tab menu
- $(".container .TabMenu span").click(function(){
- //Remove the exist selector
- $(".selector").removeClass("selector");
- //Add the selector class to the sender
- $(this).addClass("selector");
-
- //Find the width of a tab
- var TabWidth = $(".TabContent:first").width();
- if(parseInt($(".TabContent:first").css("margin-left")) > 0)
- TabWidth += parseInt($(".TabContent:first").css("margin-left"));
- if(parseInt($(".TabContent:first").css("margin-right")) >0)
- TabWidth += parseInt($(".TabContent:first").css("margin-right"));
- //But wait, how far we slide to? Let find out
- var newLeft = -1* $("span").index(this) * TabWidth;
- //Ok, now slide
- $(".AllTabs").animate({
- left: + newLeft + "px"
- },1000);
- });
- });
-
- </script>
css:
- <style type="text/css">
-
-
-
-
- .selector
- {
- background: url(img/selector.png);
- }
- .hovering
- {
- background: url(img/selector.png);
- opacity: 0.5;
- }
- .container .TabMenu
- {
- position: relative;
- top: 0px;
- left: 0px;
- z-index: 10;
- }
- .container .TabMenu span
- {
- display: inline-block;
- height: 77px;
- margin: 0px;
- padding:0px;
- }
- .container .ContentFrame
- {
- width: 980px;
-
- left: 0px;
- overflow:hidden;
- color: #fff;
- float:left;
- }
-
-
-
-
-
-
-
- .container .ContentFrame .AllTabs
- {
- position: relative;
- left:0px;
- width: 2940px;
- overflow:hidden;
- z-index: 2;
- }
- .container .ContentFrame .AllTabs .TabContent
- {
- width:980px;
- background-color:#393;
- text-align: justify;
- float:left;
- overflow:hidden;
- }
-
- .TabMenu
- {
- background: url(img/slideTabbg_middel.png);
- background-repeat:repeat-x;
- }
- .TabMenu_top_left
- {
- background: url(img/slideTabbg_left.png);
- background-repeat:no-repeat;
- width: 7px;
- height:77px;
- float:left;
- }
- .TabMenu_top_right
- {
- background: url(img/slideTabbg_right.png);
- background-repeat:no-repeat;
- width: 7px;
- height:77px;
- float:right;
- }
- .Content_middel_left
- {
- background: url(img/Content_middel_left.png);
- background-repeat:no-repeat;
- background-size: 100%;
- width: 7px;
- height:100%;
- float:left;
- }
-
-
- .Content_middel_right
- {
- background: url(img/Content_middel_left.png);
- background-repeat:no-repeat;
- background-size: 100%;
- width: 7px;
- height:100%;
- float:right;
- z-index: 5;
- }
-
- .TabMenu_footer {
- bottom: 0px;
- left: 0px;
- z-index: 10;
- width: 100%;
- height:9px;
- float:left;
- background: url(img/slideTabbg_middel_footer.png);
- background-repeat:repeat-x;
- position: fixed;
- }
- .TabMenu_footer_left
- {
- background: url(img/slideTabbg_middel_footer_left.png);
- background-repeat:no-repeat;
- height:9px;
- width: 6px;
- float:left;
- }
- .TabMenu_footer_right
- {
- background: url(img/slideTabbg_middel_footer_right.png);
- background-repeat:no-repeat;
- width: 6px;
- height:9px;
- float:right;
- }
- img#bg {
- width:7px;
- height:100%;
- }
-
- .Contentcenter{
- position: relative;
- width: 980px;
- overflow:hidden;
- align:center;margin:0 auto;
- }
- </style>
body:
- <div class="container">
- <div class="TabMenu">
-
-
-
- <span>
- 1
- </span>
- <span>
- <img src="img/ipod.png" />
- </span>
- <span>
- <img src="img/drive.png" />
- </span>
-
-
- </div>
-
-
-
- <div class="Contentcenter">
- <div class="ContentFrame">
- <div class="AllTabs">
- <div class="TabContent">
- <p>
- 1! Site! Test!
- </p>
- </div>
- <div class="TabContent">
- <p>
- 2! Site! Test!
- </p>
- </div>
- <div class="TabContent">
- <p>
- 3! Site! Test!<br/>
-
- </p>
- </div>
- </div>
- </div>
- </div>
-
-
- </div>
samlet:
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Untitled Document</title>
-
-
- <!-- JAVASCRIPT -->
- <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
- <script type="text/javascript">
-
- $(document).ready(function(){
- //Initialize
- //Set the selector in the first tab
- $(".container .TabMenu span:first").addClass("selector");
-
-
- //Basic hover action
- $(".container .TabMenu span").mouseover(function(){
- $(this).addClass("hovering");
- });
- $(".container .TabMenu span").mouseout(function(){
- $(this).removeClass("hovering");
- });
-
- //Add click action to tab menu
- $(".container .TabMenu span").click(function(){
- //Remove the exist selector
- $(".selector").removeClass("selector");
- //Add the selector class to the sender
- $(this).addClass("selector");
-
- //Find the width of a tab
- var TabWidth = $(".TabContent:first").width();
- if(parseInt($(".TabContent:first").css("margin-left")) > 0)
- TabWidth += parseInt($(".TabContent:first").css("margin-left"));
- if(parseInt($(".TabContent:first").css("margin-right")) >0)
- TabWidth += parseInt($(".TabContent:first").css("margin-right"));
- //But wait, how far we slide to? Let find out
- var newLeft = -1* $("span").index(this) * TabWidth;
- //Ok, now slide
- $(".AllTabs").animate({
- left: + newLeft + "px"
- },1000);
- });
- });
-
- </script>
- <!-- JAVASCRIPT -->
-
- <!-- CSS -->
- <style type="text/css">
-
-
-
-
- .selector
- {
- background: url(img/selector.png);
- }
- .hovering
- {
- background: url(img/selector.png);
- opacity: 0.5;
- }
- .container .TabMenu
- {
- position: relative;
- top: 0px;
- left: 0px;
- z-index: 10;
- }
- .container .TabMenu span
- {
- display: inline-block;
- height: 77px;
- margin: 0px;
- padding:0px;
- }
- .container .ContentFrame
- {
- width: 980px;
-
- left: 0px;
- overflow:hidden;
- color: #fff;
- float:left;
- }
-
-
-
-
-
-
-
- .container .ContentFrame .AllTabs
- {
- position: relative;
- left:0px;
- width: 2940px;
- overflow:hidden;
- z-index: 2;
- }
- .container .ContentFrame .AllTabs .TabContent
- {
- width:980px;
- background-color:#393;
- text-align: justify;
- float:left;
- overflow:hidden;
- }
-
- .TabMenu
- {
- background: url(img/slideTabbg_middel.png);
- background-repeat:repeat-x;
- }
- .TabMenu_top_left
- {
- background: url(img/slideTabbg_left.png);
- background-repeat:no-repeat;
- width: 7px;
- height:77px;
- float:left;
- }
- .TabMenu_top_right
- {
- background: url(img/slideTabbg_right.png);
- background-repeat:no-repeat;
- width: 7px;
- height:77px;
- float:right;
- }
- .Content_middel_left
- {
- background: url(img/Content_middel_left.png);
- background-repeat:no-repeat;
- background-size: 100%;
- width: 7px;
- height:100%;
- float:left;
- }
-
-
- .Content_middel_right
- {
- background: url(img/Content_middel_left.png);
- background-repeat:no-repeat;
- background-size: 100%;
- width: 7px;
- height:100%;
- float:right;
- z-index: 5;
- }
-
- .TabMenu_footer {
- bottom: 0px;
- left: 0px;
- z-index: 10;
- width: 100%;
- height:9px;
- float:left;
- background: url(img/slideTabbg_middel_footer.png);
- background-repeat:repeat-x;
- position: fixed;
- }
- .TabMenu_footer_left
- {
- background: url(img/slideTabbg_middel_footer_left.png);
- background-repeat:no-repeat;
- height:9px;
- width: 6px;
- float:left;
- }
- .TabMenu_footer_right
- {
- background: url(img/slideTabbg_middel_footer_right.png);
- background-repeat:no-repeat;
- width: 6px;
- height:9px;
- float:right;
- }
- img#bg {
- width:7px;
- height:100%;
- }
-
- .Contentcenter{
- position: relative;
- width: 980px;
- overflow:hidden;
- align:center;margin:0 auto;
- }
- </style>
- <!-- CSS -->
-
-
- </head>
- <body>
-
- <div class="container">
- <div class="TabMenu">
-
-
-
- <span>
- 1
- </span>
- <span>
- 2
- </span>
- <span>
- 3
- </span>
-
-
- </div>
-
-
-
- <div class="Contentcenter">
- <div class="ContentFrame">
- <div class="AllTabs">
- <div class="TabContent">
- <p>
- 1
- </p>
- </div>
- <div class="TabContent">
- <p>
- 2
- </p>
- </div>
- <div class="TabContent">
- <p>
- 3
- </p>
- </div>
- </div>
- </div>
- </div>
-
-
- </div>
-
- </body>
- </html>
Mvh lasse , Mange tak
Indlæg senest redigeret d. 24.10.2011 15:20 af Bruger #16514