Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> ([CSS])Rozwijane menu
ShadowD
post
Post #1





Grupa: Zarejestrowani
Postów: 1 333
Pomógł: 137
Dołączył: 25.03.2008
Skąd: jesteś??

Ostrzeżenie: (0%)
-----


Mam kody do rozwijanego menu w dół i w lewo oto one:

Lewe kod:

  1. body { behavior: url(qw.htc);}
  2.  
  3. #menu {width:100px; position: relative; margin-bottom:3px}
  4. #menu #tytul {background-image: url('1.bmp'); width:100px; height:21px;}
  5. #menu #tytul2 {position:absolute; top:0px; visibility:hidden; background-image: url('2.bmp'); width:103px; height:21px;}
  6. #menu #lista {position:absolute; top:0px; left:103px; visibility:hidden;}
  7. #menu #tytul, #tytul2, a {background-repeat: no-repeat;}
  8. #menu a {display:block; width:100px; height:21px; background-image: url('forum.bmp'); margin-bottom:3px;}
  9. #menu:hover #lista {visibility:visible;}
  10. #menu:hover #tytul2 {visibility:visible;}
  11.  
  12. <div id='menu'>
  13. <div id='tytul'></div>
  14. <div id='tytul2'></div>
  15. <div id='lista'>
  16. <a href=#></a>
  17. <a></a>
  18. <a></a>
  19. <a></a>
  20. </div></div>
  21. <div id='menu'>
  22. <div id='tytul'></div>
  23. <div id='tytul2'></div>
  24. <div id='lista'>
  25. <a></a>
  26. <a></a>
  27. <a></a>
  28. <a></a>
  29. </div></div>
  30. <div id='menu'>
  31. <div id='tytul'></div>
  32. <div id='tytul2'></div>
  33. <div id='lista'>
  34. <a></a>
  35. <a></a>
  36. <a></a>
  37. <a></a>
  38. </div></div>
  39. <div id='menu'>
  40. <div id='tytul'></div>
  41. <div id='tytul2'></div>
  42. <div id='lista'>
  43. <a></a>
  44. <a></a>
  45. <a></a>
  46. <a></a>
  47. </div></div>


Dolne kod:

  1. body { behavior: url(qw.htc);}
  2.  
  3. div {width:100px;}
  4. div a {display:block; border:1px solid black; width:100px; text-align:center;}
  5. div p {margin:0px; visibility:hidden; position:absolute;}
  6.  
  7. div #menu {font-weight:600}
  8. div #lista {margin-top:3px;}
  9.  
  10. div:hover p {visibility:visible;}
  11.  
  12.  
  13. <div>
  14. <a id='menu'>Menu</a>
  15. <p>
  16. <a id='lista'>qwqw</a>
  17. <a id='lista'>qwqw</a>
  18. </p>
  19. </div>


Są to moje projekty a wiec udostępniam je, starałem się by działały pod najważniejszymi przeglądarkami i działają z wyjątkiem ie lecz i na to znalazłem sposób kod JS który już nie jest moim autorstwem kod:

  1. <attach event="ondocumentready" handler="parseStylesheets" />
  2. <script language="JScript">
  3.  
  4. var currentSheet, doc = window.document, activators = {
  5. onhover:{on:'onmouseover', off:'onmouseout'},
  6. onactive:{on:'onmousedown', off:'onmouseup'}
  7. }
  8.  
  9. function parseStylesheets() {
  10. var sheets = doc.styleSheets, l = sheets.length;
  11. for(var i=0; i<l; i++)
  12. parseStylesheet(sheets[i]);
  13. }
  14. function parseStylesheet(sheet) {
  15. if(sheet.imports) {
  16. try {
  17. var imports = sheet.imports, l = imports.length;
  18. for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
  19. } catch(securityException){}
  20. }
  21.  
  22. try {
  23. var rules = (currentSheet = sheet).rules, l = rules.length;
  24. for(var j=0; j<l; j++) parseCSSRule(rules[j]);
  25. } catch(securityException){}
  26. }
  27.  
  28. function parseCSSRule(rule) {
  29. var select = rule.selectorText, style = rule.style.cssText;
  30. if(!(/(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i).test(select) || !style) return;
  31.  
  32. var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
  33. var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
  34. var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
  35. var affected = select.replace(/:hover.*$/, '');
  36. var elements = getElementsBySelect(affected);
  37.  
  38. currentSheet.addRule(newSelect, style);
  39. for(var i=0; i<elements.length; i++)
  40. new HoverElement(elements[i], className, activators[pseudo]);
  41. }
  42.  
  43. function HoverElement(node, className, events) {
  44. if(!node.hovers) node.hovers = {};
  45. if(node.hovers[className]) return;
  46. node.hovers[className] = true;
  47. node.attachEvent(events.on,
  48. function() { node.className += ' ' + className; });
  49. node.attachEvent(events.off,
  50. function() { node.className =
  51. node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
  52. }
  53.  
  54. function getElementsBySelect(rule) {
  55. var parts, nodes = [doc];
  56. parts = rule.split(' ');
  57. for(var i=0; i<parts.length; i++) {
  58. nodes = getSelectedNodes(parts[i], nodes);
  59. } return nodes;
  60. }
  61. function getSelectedNodes(select, elements) {
  62. var result, node, nodes = [];
  63. var classname = (/\.([a-z0-9_-]+)/i).exec(select);
  64. var identify = (/\#([a-z0-9_-]+)/i).exec(select);
  65. var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');
  66. for(var i=0; i<elements.length; i++) {
  67. result = tagName? elements[i].all.tags(tagName):elements[i].all;
  68. for(var j=0; j<result.length; j++) {
  69. node = result[j];
  70. if((identify && node.id != identify[1]) || (classname && !(new RegExp('\\b' +
  71. classname[1] + '\\b').exec(node.className)))) continue;
  72. nodes[nodes.length] = node;
  73. }
  74. } return nodes;
  75. }


Trzeba go zapisać jako plik "qw.htc".

WAŻNE NIE POZWALAM SIĘ PODPISWAĆ POD AUTORSTWEM TEGO SKRYPTU!!

Może przydadzą się komuś łatwo je edytować... smile.gif

Ten post edytował ShadowD 28.03.2008, 22:06:21


--------------------
Mój blog - o wszystkim i niczym ale zazwyczaj związane z informatyką! ;-)
Githube

Usługi spawalnicze i monterskie | Park linowy Lublin i Okunince
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 17:03