Skip to content

Commit

Permalink
El control color de HTML5
Browse files Browse the repository at this point in the history
  • Loading branch information
calirojas committed Aug 3, 2013
1 parent ba5abd4 commit 483b110
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
52 changes: 52 additions & 0 deletions control-color-html5/css/color.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
*{
padding: 0;
margin: 0;
}
body{
background: #ccc;
font: normal 12px Arial, Verdana, Tahoma, sans-serif;
color: #000;
}
a{
color: #f00;
}
input[type="color"]{
height: 100px;
width: 200px;
}
h1{
font-size: 24px;
}
#divContenedor{
width: 600px;
margin: 0 auto;
margin-top: 70px;
background: #fff;
border-radius: 3px;
box-shadow: 0 0 10px #666;
padding-bottom: 20px;
}
#divInfo{
text-align: center;
padding: 15px;
}
#divSelector{
padding: 10px;
text-align: center;
}
#divColor{
background: #ff006f;
text-align: center;
padding: 20px 0;
width: 200px;
margin: 0 auto;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
border-radius: 3px;
font-size: 30px;
color: #fff;
text-shadow: 1px 1px 10px #000;
}
38 changes: 38 additions & 0 deletions control-color-html5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>Ejemplo del control color de HTML5 - w ww.lewebmonster.com</title>
<link rel="stylesheet" type="text/css" href="css/color.css">
</head>
<body>
<div id="divContenedor">
<div id="divInfo">
<h1>El control "color" de HTML5</h1>
<p>
Ejemplo por Cali Rojas -
<a href="http://www.lewebmonster.com">www.lewebmonster.com</a>
</p>
</div>
<div id="divSelector">
<p><strong>- seleccione un color haciendo clic -</strong></p>
<input type="color" id="clrColor" value="#ff006f">
<p><strong>- el color seleccionado es -</strong></p>
</div>
<div id="divColor">#ff006f</div>
</div>
<script>
//escuchamos el evento change del control
document.getElementById('clrColor').addEventListener('change',function(){
//obtenemos el color seleccionado por el usuario
var strColorSeleccionado=this.value;
//seleccionamos la capa que vamos a cambiar de color
var objCapa=document.getElementById('divColor');

//le colocamos el nuevo color de fondo a la capa
objCapa.style.backgroundColor=strColorSeleccionado;
//mostramos el codigo del color seleccionado
objCapa.innerHTML=strColorSeleccionado;
});
</script>
</body>
</html>
Binary file not shown.

0 comments on commit 483b110

Please sign in to comment.