Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is transition started up with autofocus?

Tags:

html

css

firefox

I created a contact form which uses autofocus="autofocus". I have noticed weird thing, when a form has autofocus the transition on my nav is fired up. I have only noticed it in Firefox. Is there anything that I did wrong or is it just how firefox behaves(bug)?

FORM:

<form method="post" action="" id="contactForm">
    <textarea id="contactF" name="message" autofocus="autofocus" tabindex="1" placeholder="Type your message here" required="required"></textarea>
    <input type="submit" id="contactS" name="submit" value="Send" tabindex="3" />
    Your Name: <input type="text" id="contactN" name="name" tabindex="2" placeholder="Type your Name" required="required" />
</form>

CSS for Nav:

#menu ul li {
    width: 251px;
    text-align:center;
    display: inline-block;
    background: #ddd;
    height: 30px;
    line-height: 30px;
    box-shadow: 126px 0 0px 0px #000 inset, -126px 0 0px 0px #000 inset;
    -webkit-transition: all 400ms ease-in;
    -moz-transition: all 400ms ease-in;
    -o-transition: all 400ms ease-in;
    transition: all 400ms ease-in;
}

}

#menu ul li:hover, #menu li.active {
    box-shadow: 0 0 0px 0px #000 inset, -0 0 0px 0px #000 inset;
}

#menu ul a:link,#menu  ul a:visited {
    display: block;
    font-size: 17px;
    width: 251px;
    text-decoration: none;
    font-weight: bold;
    color: #6DB7B5;
    margin:0 auto;
    -webkit-transition: all 400ms ease-out;
    -moz-transition: all 400ms ease-out;
    -o-transition: all 400ms ease-out;
    transition: all 400ms ease-out;
}

#menu ul a:hover, #menu li.active a {
    color: #FF6181;
}
like image 750
Dharman Avatar asked Nov 03 '22 22:11

Dharman


1 Answers

Ok new try, after some reading i found out that could be a general problem with transitions. There is only one fix if this happens.

you have to add a class to your body

<body class="preload">

this class gets no transition at all

.preload * {
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -ms-transition: none !important;
  -o-transition: none !important;
}

And in the end you have to remove the preload class with a little js.

$("window").load(function() {
  $("body").removeClass("preload");
});

Hope this helps, feedback would be nice

like image 166
Denny Mueller Avatar answered Nov 11 '22 06:11

Denny Mueller