Forum Moderators: not2easy
Anyway here is the code but I just can't figure out how this is all put together as I never use this method.
My css tends to look like this...
li.menu {}
Here is the code...also I do not know what these menus say but I know they are in Spanish?
CSS
#nav, #nav ul{
float: left;
width: 755px;
padding: 0;
margin: 0;
list-style: none;
border: solid #ffffff;
border-width: 4px 0px 4px 0px;
line-height: 1;
z-index: 100;
}#nav a {
display: block;
font: normal 11px arial;
color: #ffffff;
text-decoration: none;
padding: 1px 0px 1px 5px;
}#nav li ul a {
display: block;
font: normal 11px arial;
color: #ffffff;
text-decoration: none;
padding: 1px 0px 1px 5px;}
#nav li {
float: left;
width: 125px;
background: #315BA2;
}#nav li ul {
position: absolute;
width: 125px;
left: -999em;
border: 1px solid #315BA2;
background: #ffffff;
font-weight: bold;
}#nav li li {
width: 125px;
}
#nav li:hover ul {
left: auto;
font: 11px bold arial;
color: #ffffff;
}#nav li:hover ul, #nav li.sfhover ul {
left: auto;
}#nav li:hover, #nav li.sfhover {
background: #9DC1DD;
}
HMTL
<ul id="nav">
<li id="first"><a href="#">¿Quienes Somos?</a>
<ul>
<li><a href="resena.php">Reseña</a></li>
<li><a href="mision.php">Misión</a></li>
<li><a href="vision.php">Visión</a></li><li><a href="historia.php">Historia</a></li>
</ul>
</li><li><a href="programas.php">Programas y Servicios</a>
<ul>
<li><a href="curriculum.php">Curriculum por Edades</a></li>
<li><a href="centros.php">Centros</a></li><li><a href="nutricion.php">Nutrición</a></li>
<li><a href="transporte.php">Transporte</a></li>
<li><a href="enfermedades.php">Enfermedades</a></li>
<li><a href="emergencias.php">Emergencias</a></li>
</ul>
</li><li><a href="#">Ventajas y Calidad</a>
<ul>
<li><a href="filosofia.php">Nuestra Filosofía</a></li>
<li><a href="modelo.php">Modelo Educativo</a></li>
<li><a href="recurso.php">Recurso Humano</a></li>
<li><a href="instalaciones.php">Diseño de Instalaciones</a></li><li><a href="lista.php">Lista de Calidad</a></li>
</ul>
</li><li><a href="sitios.php">Sitios de Interés</a>
<ul>
<li><a href="sitios.php">Premios, prensa</a></li>
<li><a href="sitios.php">Convenios</a></li><li><a href="sitios.php">Colegios</a></li>
<li><a href="sitios.php">Asociaciones</a></li>
<li><a href="sitios.php">Fundaciones</a></li>
</ul>
</li><li><a href="#">Tour y Fotos</a>
<ul>
<li><a href="fotos.php">Fotos Niños</a></li>
<li><a href="mapa.php">Mapa del Tour</a></li>
<li><a href="fotosinstalaciones.php">Fotos Instalaciones</a></li>
</ul>
</li><li id="last"><a href="contacto.php">Contáctenos</a>
<ul>
<li><a href="contacto.php">Registracion</a></li>
<li><a href="contacto.php">Teléfono</a></li>
<li><a href="contacto.php">Dirección</a></li>
<li><a href="contacto.php">Correo Electrónico</a></li>
<li><a href="contacto.php">FAQs</a></li></ul>
</li>
</ul>
However, there's no inherent conflict between using id in javascript and using id in css. It can be very useful to use a CSS id (which is only applied once in any html document) for unique rules -- and then also apply a class to the same element to pick up other more widely applied css rules.
The differentiator: an ID is unique - an "identity". It's used once in each html document. A class can have any number of members.
However, there's no inherent conflict between using id in javascript and using id in css...
This is quite right. Moreover, ids used for javascript tend to make themselves useful for applying styles to an element as well. Similarly, ids used for css come in handy if you need to do a little client-side dom scripting. This is especially true since many of the things that the dom is most useful for involve changing css of particular elements on the fly.
A sort of weird example that occurs to me could be a simple slide show; imagine that you needed to build a simple gallery that would a) degrade nicely absent javascript, and b) cycle through the images if javascript were present.
You could build a tool like this in this way:
In reality, this is probably not a really great method for making a slide show, but maybe it shows that using ids only for javascript or only for css could be restrictive; for example, there is no particular reason for using ids to refer to the images in the hypothetical example. It would also be possible to get all the relevant images on the page and loop through an array of them and simply change the styles of image 'n' as needed, but the id can potentially make this simpler while providing a hook to hang styles on.
It seems to me that if you truly need to have distinct ids for use with javascript that you could achieve much the same thing by distinguishing the use of the id according to your own naming convention (e.g. #js_navigation / #css_header) without denying yourself access to the useful characteristics of the id selectors [w3.org].
-B
Simply adding a .nav and such did not achieve the goal. I come across a lot of id/css and I simply do not know how to translate it in to class/css which no one "translated" in to a form I understand.
The menu code is over sophistocated I feel and the id/css doesn't help my cause. So I just posted the code directly instead of replacing the original menu text with "menu".
which no one "translated" in to a form I understand
the code you posted only contains three IDs...nav, first and last. Here's a step-by-step for changing them into classes.
(1) Copy the code into notepad or some other simple text editor (I prefer Notepad2).
(2)Open the replace function. Type "id" into the find field, and "class" into the replace field. Run it on the whole document. You should get a "3 replacements made" message.
(3)Open the replace function again. Type "#" into the find field and "." into the replace field. Run it on the whole document. You should get a "12 replacements made" message. (Actually, it will probably say 14 changes made, as there are two href attributes in the code with a hash mark placeholder.)
(4)Use the code.
The problem may have been that you didn't swap out all the instances of the id selector (#) in the CSS. If you switch the html attribute from id to class, all the corresponding CSS selectors have to be changed, as well.
If this doesn't accomplish what you want, you may need to back up and approach your description of the problem again.
cEM
ul.nav li
This is a selector for any list-item that belongs to a list with a class of nav. You learn something new everyday!
If you find yourself repeating a class name over and over again in the HTML code, then simply attach that class name to a parent HTML block instead, and then use that "double" selector to "reach in" and style all of the child elements.
It works well with lists, tables, and forms, and with several other constructs using divs.