Cool inputs ! (part 1)
For SO question# 38332038
by Louys Patrice Bessette
HTML
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://fonts.googleapis.com/css?family=Open+Sans:300"></script>
<section id="text">
<p><span> İSİM</span><input name="name" type="text" placeholder="İsminiz" /></p>
<p><span> KONU </span><input name="subject" type="text" placeholder="Konu"/></p>
<p><span> MAİL </span><input name="mail" type="email" placeholder="Mailiniz"/></p>
<p><span> MESAJ </span><textarea name="message" type="text" placeholder="Mesajınız"></textarea>
</section>
CSS
.aktif1{width:100px;transition:1s;}
.aktif2{width:450px;transition:1s;}
body{
background:#f7f7f7;
}
p{
position: relative;
width:450px;
}
section#text{
position:relative;
margin-left:100px; /* changed (for jsFiddleview) */
margin-top:150px;
}
p input{
outline:none;
width:330px;
height:40px;
padding-left:120px;
}
p textarea{
outline:none;
max-width:330px;
max-height:40px;
width:330px;
height:40px;
padding-left:120px;
}
p span{
width:455px;
height:45px;
background:#333;
position: absolute;
color:white;
text-align:center;
line-height:50px;
font-family: 'Open Sans', sans-serif;
font-weight:bold;
transition:1s;
}
JavaScript
/* Removed all this...
$(function() {
fonk1();
$('section#text input').focus(function(){
fonk1().stop();
});
$('section#text input').blur(function(){
fonk2();
});
});
var fonk1 = function(){
*/
$('section#text p').mouseenter(function(){
$(this).children('span').css({ // Changed jQuery .anminate() for .css()
'width':'100' // and corrected the selector
});
});
/* // Removed this unusefull function wrap.
var fonk2 = function(){
*/
$('section#text p').mouseleave(function(){
$('span',this).css({
'width': '450px',
'transition': '1s'
});
});