Foros del Web » Creando para Internet » HTML »

color de celdas

Estas en el tema de color de celdas en el foro de HTML en Foros del Web. <td onMouseOver="this.style.backgroundColor='red'; " onMouseOut="this.style.backgroundColor='#000099';" ><a href="indexProvincial">Inicio</a></td> bueno este es mi código, en el cual si paso el raton por la celda pues se pone en ...
  #1 (permalink)  
Antiguo 03/04/2008, 01:29
 
Fecha de Ingreso: marzo-2008
Mensajes: 27
Antigüedad: 16 años, 1 mes
Puntos: 0
color de celdas

<td onMouseOver="this.style.backgroundColor='red'; " onMouseOut="this.style.backgroundColor='#000099';" ><a href="indexProvincial">Inicio</a></td>

bueno este es mi código, en el cual si paso el raton por la celda pues se pone en rojo y el texto inicio se keda en rojo, es un enlace, lo q yo kiero es que al pasar por encima de la celda tambien cambie el colo del texto

creo q el problema es q es un enlace y que en el estilo css tengo puesto
a:visited
a:link los dos en rojo
y en a:hover azu

no se si me expliké demasiao bien...
  #2 (permalink)  
Antiguo 03/04/2008, 01:31
 
Fecha de Ingreso: marzo-2008
Mensajes: 27
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: color de celdas

estilo css

a:link
{
color:red;
text-decoration:none;
}

a:visited
{
color:red;
text-decoration:none;
}

a:hover
{
color:#000099;
text-decoration:none;
}
  #3 (permalink)  
Antiguo 03/04/2008, 04:03
Avatar de mgusdl  
Fecha de Ingreso: abril-2007
Ubicación: Malaga, España
Mensajes: 190
Antigüedad: 17 años
Puntos: 5
Re: color de celdas

td { background:#F00; }
td:hover { background:#009; }
td a { color:red; text-decoration:none; }
td a:hover { color:#009; text-decoration:none; }

Pero tendras que cargar el parche .htc para IE para que acepte el hover sobre todos los elementos y no sólo sobre.
Agrega esto a tu indice
Código HTML:
<!--[if IE]>
<style type="text/css" media="screen">
body { behavior: url(csshover.htc); }
</style>
<![endif]--> 
Y guarda el siguiente codigo en csshover.htc
Código PHP:
<attach event="ondocumentready" handler="parseStylesheets" />
<
script>
/**
 *    Whatever:hover - V1.41.050927 - hover & active
 *    ------------------------------------------------------------
 *    (c) 2005 - Peter Nederlof
 *    Peterned - http://www.xs4all.nl/~peterned/
 *    License  - http://creativecommons.org/licenses/LGPL/2.1/
 *
 *    Whatever:hover is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    Whatever:hover is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *    Lesser General Public License for more details.
 *
 *    Credits and thanks to:
 *    Arnoud Berendsen, Martin Reurings, Robert Hanson
 *
 *    howto: body { behavior:url("csshover.htc"); }
 *    ------------------------------------------------------------
 */

var csshoverReg = /(^|s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i,
currentSheetdoc window.documenthoverEvents = [], activators = {
    
onhover:{on:'onmouseover'off:'onmouseout'},
    
onactive:{on:'onmousedown'off:'onmouseup'}
}

function 
parseStylesheets() {
    if(!/
MSIE (5|6)/.test(navigator.userAgent)) return;
    
window.attachEvent('onunload'unhookHoverEvents);
    var 
sheets doc.styleSheetssheets.length;
    for(var 
i=0i<li++) 
        
parseStylesheet(sheets[i]);
}
    function 
parseStylesheet(sheet) {
        if(
sheet.imports) {
            try {
                var 
imports sheet.importsimports.length;
                for(var 
i=0i<li++) parseStylesheet(sheet.imports[i]);
            } catch(
securityException){}
        }

        try {
            var 
rules = (currentSheet sheet).rulesrules.length;
            for(var 
j=0j<lj++) parseCSSRule(rules[j]);
        } catch(
securityException){}
    }

    function 
parseCSSRule(rule) {
        var 
select rule.selectorTextstyle rule.style.cssText;
        if(!
csshoverReg.test(select) || !style) return;
        
        var 
pseudo select.replace(/[^:]+:([a-z-]+).*/i'on$1');
        var 
newSelect select.replace(/(.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi'.$2' pseudo);
        var 
className = (/.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
        var 
affected select.replace(/:(hover|active).*$/, '');
        var 
elements getElementsBySelect(affected);
        if(
elements.length == 0) return;

        
currentSheet.addRule(newSelectstyle);
        for(var 
i=0i<elements.lengthi++)
            new 
HoverElement(elements[i], classNameactivators[pseudo]);
    }

function 
HoverElement(nodeclassNameevents) {
    if(!
node.hoversnode.hovers = {};
    if(
node.hovers[className]) return;
    
node.hovers[className] = true;
    
hookHoverEvent(nodeevents.on, function() { node.className += ' ' className; });
    
hookHoverEvent(nodeevents.off, function() { node.className node.className.replace(new RegExp('\\s+'+className'g'),''); });
}
    function 
hookHoverEvent(nodetypehandler) {
        
node.attachEvent(typehandler);
        
hoverEvents[hoverEvents.length] = { 
            
node:nodetype:typehandler:handler 
        
};
    }

    function 
unhookHoverEvents() {
        for(var 
e,i=0i<hoverEvents.lengthi++) {
            
hoverEvents[i]; 
            
e.node.detachEvent(e.typee.handler);
        }
    }

function 
getElementsBySelect(rule) {
    var 
partsnodes = [doc];
    
parts rule.split(' ');
    for(var 
i=0i<parts.lengthi++) {
        
nodes getSelectedNodes(parts[i], nodes);
    }    return 
nodes;
}
    function 
getSelectedNodes(selectelements) {
        var 
resultnodenodes = [];
        var 
identify = (/#([a-z0-9_-]+)/i).exec(select);
        
if(identify) return [doc.getElementById(identify[1])];
        
        var 
classname = (/.([a-z0-9_-]+)/i).exec(select);
        var 
tagName select.replace(/(.|#|\:)[a-z0-9_-]+/i, '');
        
var classReg classname? new RegExp('\\b' classname[1] + '\\b'):false;
        for(var 
i=0i<elements.lengthi++) {
            
result tagNameelements[i].all.tags(tagName):elements[i].all
            for(var 
j=0j<result.lengthj++) {
                
node result[j];
                if(
classReg && !classReg.test(node.className)) continue;
                
nodes[nodes.length] = node;
            }
        }    return 
nodes;
    }
</script> 

Última edición por mgusdl; 03/04/2008 a las 04:08 Razón: cambios en los colores
  #4 (permalink)  
Antiguo 03/04/2008, 04:52
 
Fecha de Ingreso: marzo-2008
Mensajes: 27
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: color de celdas

muchas gracias;)
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:23.