menúes y la class .selected

15/Mar/2007 966

Por usabilidad, siempre es recomendable dejarle claro al usuario dónde está parado dentro del sitio. Existen varias maneras de hacerlo, desde dejar evidente en el <title> en qué sección se está, pasando por mostrar un pequeño mapa de navegación desde y hasta dónde está ubicado (Inicio > Quiénes Somos > Empleados por ejemplo) o dejar seleccionado en el menú de navegación dónde uno está parado, con una clase especial. En este caso, en sitios pequeños a medianos, recomiendo utilizar un pequeño y simple truco que involucra HTML y CSS.

Hagamos un layout muy simple. En este caso, un menú con listas y un contenido sólo para que no esté tan vacío (reciclaré el HTML de un post anterior):

<div id="menulateral">
     <ul>
          <li><a href="#" class="selected1">Item Uno</a></li>
          <li><a href="#" class="selected2">Item Dos</a></li>
          <li><a href="#" class="selected3">Item Tres</a></li>
     </ul>
</div>
<div id="contenido">
     <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec ut risus hendrerit sem adipisc………</p>
</div>

Como se dieron cuenta, cada ítem del menú tiene una class="selected" con diferencias numéricas consecutivas (este es mi criterio, utilicen el que más les convenga) . El truco está en darle al <body> un ID específico, en este caso será uno para cada sección de nuestro menú, en total 3. Con este ID, mediante CSS le daremos un estilo para cada class selected, así si nos encontramos ubicados por ejemplo en el HTML con el id="item2", gatillará que la class selected2 de ese ID será desplegada. ¿Se entendió? Mejor sigo con el código CSS para que quede más claro:

body#item1 a.selected1, body#item2 a.selected2, body#item3 a.selected3 {
     text-decoration: none;
     padding-left: 10px;
}

Entonces, nuevamente, tenemos 3 páginas HTML cada una con un ID diferente, de acuerdo con la sección en que estamos. Cada <a> del menú tiene una class diferente también, para poder diferenciarlas. La idea es con el CSS poder manejar el estilo para mostrar al usuario que estamos ubicados en esa parte del sitio sin tener que tocar el HTML, basta con dejar las classes siempre puestas, pero con diferentes ID’s en el < body>.

Ver HTML final (view source para más detalles)

Ver Hoja de Estilos Final

Comentarios

  1. betnovate 0 1 buy [#]

    comment4, where to buy micronase, 3793, stromectol buy, 96725, combivent for sale, hspfb, buy pilex, odz, propecia uk, nxc, where to buy epivir, szrog, shallaki for sale, ziku, buy bactrim online, >:D, inderal uk, qpbwrc, fluoxetine, zcqcco, lumigan for sale, 055796, buy pamelor online, rbnppm, buy differin, 665, confido uk, :-(, uroxatral uk, cuuw,

  2. zyloprim uk [#]

    comment4, buy tadapox uk, wvapuc, endep for sale uk, nqviil, hyzaar buy, 45824, where to buy acticin, dxomtr, nortriptyline for sale, vie, buy maxolon uk, nhflzt, ponstel, 3098, arava uk, =-))), requip buy, 193765, myambutol for sale uk, dgvnz, casodex buy, 3274, buy dapsone uk, lug, advair diskus, gqrfs, female viagra for sale, lzq, lanoxin buy, verh, seroquel buy, 9671, dulcolax for sale, 8-(((, buy pilex, 469555, buy micardis online, oxtkhm, xeloda buy, 39392, alesse buy, bks, zyrtec uk, 205067,

  3. himcolin [#]

    comment4, buy anaprox online, 608, where to buy benadryl, vloelu, where to buy zyban, rdp, lipitor for sale uk, 971, emsam uk, 34438, desyrel for sale uk, iyfux, buy cefixime uk, >:OOO, zyrtec for sale, 129001, eulexin uk, :-((, buy topamax uk, lsyfwb, keflex, 93309, where to buy lioresal, 8-[, buy betapace uk, 981, buy lipitor, ihthng, buy requip uk, 571022, buy abilify, =D, dilantin buy, 558, buy aggrenox uk, 40094, hytrin for sale uk, :-OO, where to buy ventolin, %[[, buy erythromycin, %-DD, buy hyzaar uk, 377586,

  4. HenryUnfiP [#]

    young gay men dating older men
    gay furry dating 2021
    dating gay men atlanta ga

  5. moncler jackets [#]

    I am also writing to let you be aware of what a excellent discovery my wife’s princess developed browsing your web site. She discovered too many things, including what it’s like to have an ideal teaching mood to let folks really easily know specified grueling issues. You really exceeded our expected results. Thanks for churning out such effective, trusted, revealing and unique thoughts on that topic to Mary.

  6. spongebob kyrie 5 [#]

    I must show my appreciation to the writer for rescuing me from this type of challenge. As a result of checking throughout the search engines and finding advice which are not pleasant, I assumed my entire life was gone. Being alive devoid of the solutions to the problems you’ve resolved by way of your main website is a serious case, as well as the kind which may have badly affected my career if I had not discovered your blog. Your actual natural talent and kindness in maneuvering all the details was crucial. I’m not sure what I would’ve done if I hadn’t come across such a stuff like this. I’m able to now relish my future. Thanks so much for this professional and result oriented guide. I will not hesitate to propose your site to anybody who should have assistance about this problem.

  7. kobe sneakers [#]

    My wife and i got absolutely fulfilled that Raymond managed to conclude his research through your precious recommendations he made when using the web site. It is now and again perplexing to simply choose to be making a gift of guidelines that some people have been selling. And we also do know we need you to be grateful to because of that. All of the explanations you have made, the straightforward website menu, the friendships you aid to promote – it’s everything superb, and it’s really aiding our son and our family understand this idea is fun, and that is very mandatory. Thank you for the whole thing!

  8. kyrie 7 [#]

    A lot of thanks for all of the efforts on this blog. My mum take interest in carrying out investigation and it’s really easy to see why. My spouse and i notice all about the lively means you render helpful secrets by means of your website and even improve participation from the others on that matter plus our daughter is truly discovering so much. Enjoy the remaining portion of the year. Your conducting a pretty cool job.

  9. golden goose outlet [#]

    I wanted to put you this little bit of word to finally give many thanks as before relating to the nice things you have contributed above. It was certainly remarkably generous with you giving without restraint all most of us might have made available as an e-book in making some bucks for themselves, precisely since you might well have tried it if you ever decided. Those ideas also served to become a great way to know that other individuals have similar zeal just like my own to see a good deal more with respect to this problem. I’m sure there are a lot more enjoyable opportunities ahead for those who read through your site.

  10. jordan shoes [#]

    I precisely needed to appreciate you yet again. I do not know the things that I would have taken care of in the absence of the type of smart ideas shared by you about this topic. Previously it was a intimidating dilemma in my position, nevertheless witnessing the very specialised style you treated it forced me to leap over happiness. Now i am grateful for your work and as well , sincerely hope you recognize what an amazing job your are undertaking teaching the mediocre ones via your site. More than likely you have never come across all of us.

  11. retro jordans [#]

    I must express thanks to this writer just for bailing me out of this particular instance. Right after searching through the search engines and getting solutions which are not pleasant, I figured my entire life was well over. Being alive minus the answers to the difficulties you’ve fixed by way of your main review is a crucial case, as well as ones which might have adversely damaged my entire career if I hadn’t come across your website. Your own natural talent and kindness in dealing with the whole thing was vital. I am not sure what I would have done if I had not encountered such a step like this. It’s possible to now look ahead to my future. Thanks so much for your specialized and result oriented help. I will not hesitate to propose your web sites to anyone who requires direction about this subject matter.

  12. birkin bag [#]

    I just wanted to write a simple remark in order to appreciate you for these pleasant information you are posting on this website. My prolonged internet look up has at the end been recognized with really good concept to share with my relatives. I would believe that we readers are truly fortunate to live in a magnificent site with so many brilliant individuals with useful principles. I feel truly privileged to have come across the website page and look forward to really more pleasurable minutes reading here. Thanks once again for all the details.

  13. moncler jackets [#]

    I would like to express some thanks to you for rescuing me from this type of incident. After scouting through the the net and finding ideas that were not powerful, I believed my life was well over. Being alive without the solutions to the problems you’ve sorted out through your good report is a critical case, and ones that could have in a negative way damaged my career if I hadn’t noticed your web blog. Your personal competence and kindness in dealing with every part was useful. I am not sure what I would have done if I hadn’t come upon such a step like this. I can now look ahead to my future. Thanks for your time very much for the impressive and sensible guide. I will not hesitate to refer your web blog to anyone who ought to have direction about this problem.

  14. buymodafinilreddit [#]

    https://provigilandmodafinil.com/ modafinil reviews

  15. bactrim and alcohol [#]

    trimethoprim sulfamethoxazole dosage trimoxazole syrup uses

  16. buymodafinilreddit [#]

    modafinil online modafinil half life

CSSLab