473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Change speed of transition

KeredDrahcir
426 256MB
I've got a dropdown menu that uses lists to achieve it. The sub menu has a height of 0 and then the hight changes when the user hovers over it.

The limit of the animation is that I can't set the max-height as auto so I've set it to a value that it unlikley that the sub menu will ever reach.

Since the tranistion time is based on the max-height is is very fast so I've slowed it down to be a suitable speed but what I'd like is to have is disappear a lot faster when someone un-hovers or even have it disppear immediately. Is there a way to do this?
Expand|Select|Wrap|Line Numbers
  1. .menu ul ul{
  2.     float: left;
  3.     padding: 0;
  4.     position: absolute;
  5.     text-align: left;
  6.     width: 274px;
  7.     z-index: 1000;
  8.     max-height: 0;
  9.     overflow: hidden;
  10.     -webkit-transition: max-height 1s ease-in;
  11.         -moz-transition: max-height 1s ease-in;
  12.         -o-transition: max-height 1s ease-in;
  13.         -ms-transition: max-height 1s ease-in;
  14.         transition: max-height 1s ease-in;
  15. }
  16.  
  17. .menu ul li:hover ul, .menu li.over ul {
  18.     max-height: 999px;
  19. }
I'd like to stick to CSS but I'm willing to use JavaScript.
Mar 13 '15 #1

✓ answered by KeredDrahcir

For the basic class ( not the :hover ), just define the transition duration you want for when the list will disapear.

On hover, define a new transition duration ( the duration that the list will take to appear ).

Quick exemple here : http://codepen.io/AxelCardinaels/pen/wBQZbm

HTML :

Expand|Select|Wrap|Line Numbers
  1. <div class="text">Some texte</div>
CSS :

Expand|Select|Wrap|Line Numbers
  1. .text{
  2.   background:blue;
  3.   transition:all 0.3s ease-in-out;
  4.   -webkit-transition: all 0.3s ease-in;
  5.   -moz-transition: all 0.3s ease-in;
  6.   -o-transition: all 0.3s ease-in;
  7.         -ms-transition: all 0.3s ease-in;
  8.         transition: all 0.3s ease-in;
  9. }
  10.  
  11. .text:hover{
  12.   background:red;
  13.   transition-duration:2s;
  14. }

1 1819
KeredDrahcir
426 256MB
For the basic class ( not the :hover ), just define the transition duration you want for when the list will disapear.

On hover, define a new transition duration ( the duration that the list will take to appear ).

Quick exemple here : http://codepen.io/AxelCardinaels/pen/wBQZbm

HTML :

Expand|Select|Wrap|Line Numbers
  1. <div class="text">Some texte</div>
CSS :

Expand|Select|Wrap|Line Numbers
  1. .text{
  2.   background:blue;
  3.   transition:all 0.3s ease-in-out;
  4.   -webkit-transition: all 0.3s ease-in;
  5.   -moz-transition: all 0.3s ease-in;
  6.   -o-transition: all 0.3s ease-in;
  7.         -ms-transition: all 0.3s ease-in;
  8.         transition: all 0.3s ease-in;
  9. }
  10.  
  11. .text:hover{
  12.   background:red;
  13.   transition-duration:2s;
  14. }
Mar 19 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Heidi Wiinberg | last post by:
Does anybody has a VB code for changing the speed on a netcard. I would like to be able to change between auto 100/Full and 1000/Full. thks
3
by: Richard A. DeVenezia | last post by:
I hope this is the end of my present 'discovery' phase. I've learned alot about JavaScript in a short time and my head hurts. The following is what came out of all my questions and all the...
42
by: Mike P. | last post by:
Hello I come from the world of C++ programming, and I'm used to writing programs that are actually executed by the CPU, and that run with some semblance of performance. I have taken the time to...
41
by: Petr Jakes | last post by:
Hello, I am trying to study/understand OOP principles using Python. I have found following code http://tinyurl.com/a4zkn about FSM (finite state machine) on this list, which looks quite useful for...
11
by: Bryan | last post by:
Hi, I work for a company that is heading towards an FDA approved development process. We have always used C++ in a windows environment, and we have more than 6 years of code, applications and...
3
by: Chris288 | last post by:
Hi, I have a problem where our app when compiled in VS2005 runs about 50% the speed it attains in VS2003. This is an unmanaged C++ app. I have tried most combinations of the optimization and...
1
by: empire1986 | last post by:
Hi, is there any way that I can set up router download/upload speed? I got 3 computers that are connected to internet over netgear router and I need to change speed on every computer?
3
by: suppoor | last post by:
Hello every one , I am writing a code to generate huge transition matrix (2 order markov and one order markov) here are my question : 1) is there any available source for efficiently...
2
by: impin | last post by:
i am trying to change the default font of the site. i have edited the css file and the changed the font. everything works fine. except the nav menu font. its not changing. it is set to default...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.