I've been trying to get an effect where:
Here is what I've tried so far:
(Since it will take to much time, replaced icons with some random keyboard symbols) http://jsfiddle.net/h9EX9/
ul li { display: inline-block; list-style-type: none; margin-right: 10px; background: #eee; }
ul li span { display: inline-block; }
ul li a { display: inline-block; width: 0; height: 0; overflow: hidden; }
ul li:hover a { transition: all 1s ease-out; width: 100%; height: auto; }
This is the effect I'm trying to accomplish. Text and and width of comment slides from the right. But there are other icons besides this one. I hope its also possible to slide those when the width of the background expands.
So is this possible, if so how?
CSS :hover Selector: The :hover selector (or CSS pseudo-class) matches when the user interacts with an element with a pointing device. It is generally triggered when the user hovers over an element with the cursor (mouse pointer).
HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .
To display div element using CSS on hover a tag: First, set the div element invisible i.e display:none;. By using the adjacent sibling selector and hover on a tag to display the div element.
Here's your demo with some work done on the CSS. It's a little long winded but gets the job done without JavaScript using only CSS transitions for animation. For some reason it animated better using max-width
instead of width
but I'm not sure why.
When implementing properly, you might want to use an extra wrapper element to animate instead of the <a>
as you will have multiple <a>
elements in the "tags" button for example.
You can do this by using the jQuery hover() function here's some demo code :
<script type="text/javascript">
$(".icon").hover(function(){ $(".text").show("slide", { direction: "left" }, 1000);}, function(){ $(".text").show("slide", { direction: "right" }, 1000);});
</script>
of course you must as you've mentioned set .text's display to none and don't forget to include the jQuery script in the head section of your HTML
ps: you can replace .icon and .text by any other CSS selector to select your icon or text example ul li a so $(".icon").hover will become $("ul li a").hover
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With