Custom form file type with CSS and pulsating effect
This is a simple customized tag of type="file" using CSS3 and animation keyframing. I'm using bootstrap CSS for simple form style and FontAwesome for the icons.
This is a simple customized tag of type="file" using CSS3 and animation keyframing. I'm using bootstrap CSS for simple form style and FontAwesome for the icons.
<html lang="es">
<head>
<title>Título</title>
<meta charset="UTF-8" />
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet" />
</head>
<body>
<form role="form">
<div class="form-group">
<label for="name">Nombre</label>
<input type="text" class="form-control" id="name" />
<label for="apellidos">Apellidos</label>
<input type="text" class="form-control" id="apellidos" />
</div>
<label for="photo">Incluya una foto</label>
<div class="drag-drop">
<input type="file" multiple="multiple" id="photo" />
<span class="fa-stack fa-2x">
<i class="fa fa-cloud fa-stack-2x bottom pulsating"></i>
<i class="fa fa-circle fa-stack-1x top medium"></i>
<i class="fa fa-arrow-circle-up fa-stack-1x top"></i>
</span>
<span class="desc">Pulse aquí para añadir archivos</span>
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
<button type="reset" class="btn btn-default">Cancelar</button>
</form>
</body>
</html>
form {
form {
width: 25em;
padding: 1em;
border: 1px solid #ccc;
border-radius: .5em;
margin: 1em;
box-shadow: .25em .25em 0 #ccc;
}
/* Estilo del área del input[file] */
.drag-drop {
height: 8em;
width: 8em;
background-color: #ccc;
border-radius: 4em;
text-align: center;
color: white;
position: relative;
margin: 0 auto 1em;
}
.drag-drop span.desc {
display: block;
font-size: .7em;
padding: 0 .5em;
color: #000;
}
input[type="file"] {
height: 10em;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 3;
}
/* Estilo del área del input[file] con :hover */
.drag-drop:hover, input[type="file"]:hover {
background-color: #3276b1;
cursor: pointer;
}
.drag-drop:hover span.desc {
color: #fff;
}
.drag-drop:hover .pulsating {
animation: pulse1 1s linear infinite;
animation-direction: alternate ;
animation: pulse1 1s linear infinite;
animation-direction: alternate ;
}
/* Composición del icono de Upload con FontAwesome */
.fa-stack { margin-top: .5em; }
.fa-stack .top { color: white; }
.fa-stack .medium {
color: black;
text-shadow: 0 0 .25em #666;
}
.fa-stack .bottom { color: rgba(225, 225, 225, .75); }
/* Keyframing de la animación */
@keyframes pulse1 {
0% { color: rgba(225, 225, 225, .75); }
50% { color: rgba(225, 225, 225, 0.25); }
100% { color: rgba(225, 225, 225, .75); }
}
@-moz-keyframes pulse1 {
0% { color: rgba(225, 225, 225, .75); }
50% { color: rgba(225, 225, 225, 0.25); }
100% { color: rgba(225, 225, 225, .75); }
}
@-webkit-keyframes pulse1 {
0% { color: rgba(225, 225, 225, .75); }
50% { color: rgba(225, 225, 225, 0.25); }
100% { color: rgba(225, 225, 225, .75); }
}
@-ms-keyframes pulse1 {
0% { color: rgba(225, 225, 225, .75); }
50% { color: rgba(225, 225, 225, 0.25); }
100% { color: rgba(225, 225, 225, .75); }
}