Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/11/2005, 15:41
Avatar de AlZuwaga
AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 2 meses
Puntos: 535
personalizar DHTML pseudo select

Hola, estoy usando el pseudo select de http://slayeroffice.com/code/dhtml_select.html

Como ven en la siguiente imagen, el fondo azul de los enaces al "hover" se extiende hasta donde finaliza la palabra:


Le coloqué al estilo display:block para que el hover se "extienda" al 100% de "la caja" como se ve a continuación:


pero... como ven, se separa cada elemento! Y el problema es que ya no sé qué tocar para que "se junten" :(

El código modificado por mi es el siguiente (en negrita el display:block agregado):

Estilos:
Código:
<style type="text/css">
#dhtml_select { 
	font-family:verdana;
	font-size:10px;
	width:120px;
	height:18px;
	border-style:inset;
	border-width:2px;
	position:relative;
}

.m_dhtml_select_options {
	position:relative;
	left:-116px;
	background-color:#FFFFFF;
	padding:2px;
	text-align:left;
	border-style:none;
}

.dhtml_href {
	width:100%;
	display:block;
	height:18px;
	margin:0px;
	padding:0px;
}
.dhtml_href:link { color:#000000;text-decoration:none;}
.dhtml_href:visited { text-decoration:none;color:#000000;}
.dhtml_href:hover {
	text-decoration:none;
	color:#FFFFFF;
	background-color:darkblue;
}
.dhtml_href:active { text-decoration:none;}
#dhtml_select_dummy {
	position:absolute;
	top:0px;
	left:0px;
	width:100%;
	padding:2px;
	text-align:left;
 }
</style>
Javascript:
Código:
<script language="javascript">
// this array controls the values and text for the options. The first values is the text, the second is the value.
//dhtml_optionsArray = new Array(<% i = 1 : While Not RsK.EOF %>["<% = RsK("Keywords") %>","<% = RsK("Keywords") %>"]<% If i < RsK.RecordCount then %>,<% End if %><% RsK.MoveNext : i = i + 1 : Wend %>);
dhtml_optionsArray = new Array(["option 1",1],["option 2",2],["option 3",3],["option 4",4]);
isExpanded = false;
clicked = false;

//constants
// these match the properties as defined in the style sheet.
FONT_SIZE = 10;
SELECT_HEIGHT = 18;
SELECT_WIDTH = 230;

function buttonClicked() {
	xDoc = document.getElementById;
	obj = document.getElementById("dhtml_select_options");
	if(!isExpanded) {
		obj.style.display="block";
		isExpanded = true;
		if(!clicked) {
			clicked=true;
			obj.style.position = "absolute";
			obj.style.top = (obj.style.top+SELECT_HEIGHT) + "px";
			obj.style.width = SELECT_WIDTH + "px";
			obj.style.borderStyle = "solid";
			obj.style.borderWidth="1px;";
			rPadding = dhtml_optionsArray.length*2;
			obj.style.height = (((dhtml_optionsArray.length) * FONT_SIZE) + rPadding) + "px";
			mHTML = "";
			for(i=0;i<dhtml_optionsArray.length;i++)mHTML += "<a class=\"dhtml_href\" href=\"javascript:handleSelect(" + i + ");\">" + dhtml_optionsArray[i][0] + "</a><br>";
			obj.innerHTML += mHTML;
		}
	} else {
		document.getElementById("dhtml_select_dummy").style.display="block";
		obj.style.display="none";
		isExpanded = false;
	}
	
}

function handleSelect(mID) {
	isExpanded = false;
	document.forms.frm1.dhtml_select_value.value =  dhtml_optionsArray[mID][1];
	document.getElementById("dhtml_select_dummy").innerHTML = dhtml_optionsArray[mID][0];
	document.getElementById("dhtml_select_dummy").style.display="block";
	document.getElementById("dhtml_select_options").style.display="none";
}

function doCover() {
	if(document.getElementById("cover").style.display == "block") {
		document.getElementById("cover").style.display = "none";
	} else {
		document.getElementById("cover").style.display = "block";
	}
}
</script>


HTML:
Código:
<div id="dhtml_select">
	<img onClick="buttonClicked();" src="dhtml_select_button.gif" style="position:absolute;top:0px;left:104px;z-index:10;">
	<div id="dhtml_select_dummy">Seleccione</div>
	<div id="dhtml_select_options" class="m_dhtml_select_options"></div>
</div>
No sé si el problema este en el CSS o en alguna de las funciones de JS (que si es ésto último, estoy más cagado aun )

Si alguien sabe qué tocar...
Gracias!
__________________
...___...