overlay

    • Beste,

      Ik ben een dropdown menu aan maken, maar ik wil een overlay er in hebben in achter grond dat alleen de drop down menu naar voren komt.
      Maar krijg het niet voor elkaar want dan komt de button niet mee in de overlay,

      Dit is de script.

      Source Code

      1. {% if categories %}
      2. <div class="container" >
      3. <div id="oe_overlay" class="oe_overlay"></div>
      4. <ul id="oe_menu" class="cd-dropdown-wrapper">
      5. <a class="cd-dropdown-trigger" >{{ text_category }}</a>
      6. <nav class="cd-dropdown">
      7. <a href="#0" class="cd-close">Close</a>
      8. <ul class="cd-dropdown-content">
      9. {% for category in categories %}
      10. {% if category.children %}
      11. <li class="has-children">
      12. <a href="{{ category.href }}" class="dropdown-toggle" data-toggle="dropdown">{{ category.name }}</a>
      13. <ul class="cd-secondary-dropdown is-hidden">
      14. <li class="go-back"><a href="#0">Menu</a></li>
      15. <li class="see-all"><a href="{{ category.href }}" class="see-all">{{ text_all }} {{ category.name }}</a></li>
      16. <li class="has-children">
      17. <a href="#">{{ category.name }}</a>
      18. {% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}
      19. <ul>
      20. {% for child in children %}
      21. <li><a href="{{ child.href }}">{{ child.name }}</a></li>
      22. {% endfor %}
      23. </ul>
      24. {% endfor %}
      25. </li>
      26. </ul> <!-- .cd-secondary-dropdown -->
      27. </li> <!-- .has-children -->
      28. {% endif %}
      29. {% endfor %}
      30. </ul> <!-- .cd-dropdown-content -->
      31. </nav><!-- .cd-dropdown -->
      32. </ul>
      33. </div>
      34. {% endif %}
      35. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
      36. <script type="text/javascript">
      37. $(function() {
      38. var $oe_menu = $('#oe_menu');
      39. var $oe_menu_items = $oe_menu.children('li');
      40. var $oe_overlay = $('#oe_overlay');
      41. $oe_menu_items.bind('mouseenter',function(){
      42. var $this = $(this);
      43. $this.addClass('slided selected');
      44. $this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
      45. $oe_menu_items.not('.slided').children('div').hide();
      46. $this.removeClass('slided');
      47. });
      48. }).bind('mouseleave',function(){
      49. var $this = $(this);
      50. $this.removeClass('selected').children('div').css('z-index','1');
      51. });
      52. $oe_menu.bind('mouseenter',function(){
      53. var $this = $(this);
      54. $oe_overlay.stop(true,true).fadeTo(200, 0.6);
      55. $this.addClass('hovered');
      56. }).bind('mouseleave',function(){
      57. var $this = $(this);
      58. $this.removeClass('hovered');
      59. $oe_overlay.stop(true,true).fadeTo(200, 0);
      60. $oe_menu_items.children('div').hide();
      61. })
      62. });
      63. </script>
      Laat alles zien

      Dit is stukje van alleen de overlay css

      Source Code

      1. .oe_overlay{
      2. background:#000;
      3. opacity:0;
      4. position:fixed;
      5. top:0px;
      6. left:0px;
      7. width:100%;
      8. height:100%;
      9. }
      10. ul.oe_menu{
      11. list-style:none;
      12. position:relative;
      13. margin:30px 0px 0px 40px;
      14. width:560px;
      15. float:left;
      16. clear:both;
      17. }
      18. ul.oe_menu > li{
      19. width:112px;
      20. height:101px;
      21. padding-bottom:2px;
      22. float:left;
      23. position:relative;
      24. }
      25. ul.oe_menu > li > a{
      26. display:block;
      27. background-color:#101010;
      28. color:#aaa;
      29. text-decoration:none;
      30. font-weight:bold;
      31. font-size:12px;
      32. width:90px;
      33. height:80px;
      34. padding:10px;
      35. margin:1px;
      36. text-shadow:0px 0px 1px #000;
      37. opacity:0.8;
      38. }
      39. ul.oe_menu > li > a:hover,
      40. ul.oe_menu > li.selected > a{
      41. background:#fff;
      42. color:#101010;
      43. opacity:1.0;
      44. }
      45. .oe_wrapper ul.hovered > li > a{
      46. background:#fff;
      47. text-shadow:0px 0px 1px #FFF;
      48. }
      49. ul.oe_menu div{
      50. position:absolute;
      51. top:103px;
      52. left:1px;
      53. background:#fff;
      54. width:498px;
      55. height:180px;
      56. padding:30px;
      57. display:none;
      58. }
      59. ul.oe_menu div ul li a{
      60. text-decoration:none;
      61. color:#222;
      62. padding:2px 2px 2px 4px;
      63. margin:2px;
      64. display:block;
      65. font-size:12px;
      66. }
      67. ul.oe_menu div ul.oe_full{
      68. width:100%;
      69. }
      70. ul.oe_menu div ul li a:hover{
      71. background:#000;
      72. color:#fff;
      73. }
      74. ul.oe_menu li ul{
      75. list-style:none;
      76. float:left;
      77. width: 150px;
      78. margin-right:10px;
      79. }
      Laat alles zien