Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Biel.

estilizar texto

Recommended Posts

boa tarde a todos. direto ao ponto. Pessoal gostaria de fazer o seguinte:
selecionar item sim e exibir dentro da caixa do select a configuração do css ou seja cor verde
selecionar item não e exibir dentro da caixa do select a configuração do css ou seja cor vermelha
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style>
.sim {color: #009900; font-weight:bold; font-size:16px;} 
.nao {color: #D40000; font-weight:bold; font-size:16px;}
</style>

</head>

<body>

<select name="aprendiz">
    <option value="" selected="selected"></option>
    <option value="sim">sim</option>
    <option value="nao">não</option>
</select>


</body>
</html>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Biel, blza!

 

Segue o exemplo:

 

http://jsfiddle.net/wilnet/8m3zoz6o/

<select name="aprendiz" onChange="this.style.backgroundColor=this.options[this.selectedIndex].style.backgroundColor">

<option value="" selected="selected"></option>    
<option value="sim" style="background: #009900; font-weight:bold; font-size:16px;">Sim</option>  
<option value="nao" style="background: #D40000; font-weight:bold; font-size:16px;">não</option>
</select> 

Espero ter ajudado,

 

vlw

Compartilhar este post


Link para o post
Compartilhar em outros sites

wilnet, obrigado por postar. O código funciona.

 

Fica verde e vermelha a cor de fundo ou seja o background. Gostaria que

 

ficasse verde e vermelha a cor do texto ou seja color com esta configuração

sim   color: #009900; font-weight:bold; font-size:16px;}  
não    color: #D40000; font-weight:bold; font-size:16px;}

Compartilhar este post


Link para o post
Compartilhar em outros sites

muda lá a palavra background por color uê.

 

vc leu o código sugerido ? tentou fazer o que vc mesmo mostrou ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

william, mudei sim o background para color e funcionou normalmente.

Só que font-weight:bold; font-size:16px;  não pega

Compartilhar este post


Link para o post
Compartilhar em outros sites

Como assim ? "não pega" ?

 

Veja se é isso que vc está tentando:

<select name="aprendiz" onChange="this.style.color=this.options[this.selectedIndex].style.color; this.style.fontWeight=this.options[this.selectedIndex].style.fontWeight; this.style.fontSize=this.options[this.selectedIndex].style.fontSize">
  <option value="" selected="selected"></option>
  <option value="sim" style="color: #009900; font-weight:bold; font-size:16px;">Sim</option>
  <option value="nao" style="color: #D40000; font-weight:bold; font-size:16px;">Não</option>
</select>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.