I have searched the whole time about how can i make this spinning search bar https://dribbble.com/shots/344730--Loooong-the-search-bar. I have also searched for a code to spin an object but i did not find that either. I have also tried to use another word instead of spinning search bar such as "how to spin a photo" but i did not find anything that matches my Question. I always search before i ask but i could not find anything that matches my Question. I know how to Expand the search bar but i do not know how to spin the search icon at the end when i click on it.
Asked
Active
Viewed 380 times
-4
-
I think he wants a search bar animation that spins instead of expanding.. Is that right Omar? – nycynik Feb 07 '16 at 15:40
-
I actually have found the URL (http://jsfiddle.net/mackry/vBxqC/show/) but i dont know how can i get from this URL the html/css code. Please if anyone knows how to get the html or css from the URL then say to me as fast as you can. – Omar Hefny Feb 09 '16 at 00:14
1 Answers
0
All the code you need is found in that JSFiddle.
The HTML:
<h3>A <a href="http://goo.gl/qCtsD" target="_blank">dribbble shot</a> recreated for the web by <a href="http://dribbble.com/ryanmclaughlin">ryan mack</a>.<p>Try typing <i>etwas</i> and press enter.</p></h3>
<form>
<input id="search" type="search" name="search" />
<p></p>
</form>
The CSS:
form {
display: inline-block;
margin: 0 100px;
position: relative;
}
#search {
border: 4px solid #999;
cursor: pointer;
height: 10px;
padding: 8px;
position: relative;
width: 10px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 15px;
-moz-appearance: none;
-webkit-appearance: none;
}
#search:hover {
border-color: #199ed9;
}
#search:focus {
border-color: #199ed9;
outline: none;
width: 180px;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
}
#search.searching {
margin-left: 80px;
width: 10px;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
}
#search + p {
background: #999;
content: '';
cursor: pointer;
display: block;
height: 10px;
position: absolute;
right: 10px;
top: -8px;
width: 4px;
-moz-border-radius: 1px;
-webkit-border-radius: 1px;
border-radius: 1px;
-moz-transform: rotate(135deg);
-webkit-transform: rotate(135deg);
-moz-transform-origin: center 20px;
-webkit-transform-origin: center 20px;
}
#search + p:hover,
#search:hover + p,
#search:focus + p {
background: #199ed9;
}
#search.searching + p {
-moz-animation: rotateHandle .6s linear 6;
-webkit-animation: rotateHandle .6s linear 6;
}
@-webkit-keyframes rotateHandle {
from { -webkit-transform: rotate(135deg); }
to { -webkit-transform: rotate(-225deg); }
}
@-moz-keyframes rotateHandle {
from { -moz-transform: rotate(135deg); }
to { -moz-transform: rotate(-225deg); }
}
h3 {
color: #888;
font-size: 20px;
font-family: 'Helvetica Neue', Arial, sans-serif;
margin: 100px 100px 50px;
-webkit-font-smoothing: antialiased;
}
h3 p {
font-size: 13px;
}
a {
color: #199ed9;
font-weight: bold;
text-decoration: none
}
a:hover {
text-decoration: underline;
}
The Javascript:
var form = $('form'),
search = $('#search');
form.submit(function(e) {
e.preventDefault();
search.addClass('searching').val('');
setTimeout(function() {
search.removeClass('searching');
}, 3600);
});
/* what's with input padding? :/ */
if ($.browser.mozilla) {
search.css('padding', '3px');
}
And the guy who did it: http://dribbble.com/ryanmclaughlin

nycynik
- 7,371
- 8
- 62
- 87
-
I have tried this code before but for no reason it doesn't spin but on the this link (jsfiddle.net/mackry/vBxqC/show) it does. If anyone can please solve this or say to me the reason why it does not spin while hitting enter but on the website it does spin. – Omar Hefny Feb 09 '16 at 22:17
-
-
I mean it spins in the demo here (jsfiddle.net/mackry/vBxqC/show) but when I insert this code up there in the answer it does not spin. – Omar Hefny Feb 13 '16 at 18:35
-
right click on the page, click inspect. Then refresh the page and see if you see an error. Without a URL I can not tell what is going on. – nycynik Feb 15 '16 at 23:28
-
can you please try to put this code that you have posted up there in the answer in an html file and then try to open it and see if it spins when you type something and hit enter because i couldn't find any errors but it still not spinning. – Omar Hefny Feb 19 '16 at 11:14
-
The spinning code/css/js is all working fine. There could be tons of reasons why it wont work for you, for instance, you might have another style that is overriding on of the styles, you may not be including the javascript or you may have an error in the JS. Could also be your browser is to old. The only way at this point that anyone can help you is for you to post your code in a public place, so we can look at it. – nycynik Feb 24 '16 at 16:24