1

I read 5 tutorials about how to start a CSS-Transition with JavaScript, but it doesn't work. I'm using Safari. Here's my Code:

<html>
<head>
<title>Test</title>
<style type="text/css">
    #test{
        width: 100px;
        height: 100px;
        background-color: aqua;
        transition: width 3s linear;
    }
</style>
<script type="text/javascript">
    function test(){
        document.getElementById('test').style.width = 200+'px';
    }
</script>
    </head>
    <body>
      <div id="test">
      </div>

      <button onclick="test()">Los</button>
    </body>
    </html>
2

1 Answer 1

3

You may need to use vendor prefixes, safari uses webkit so try addind the -webkit- prefix.

<style type="text/css">
    #test{
        width: 100px;
        height: 100px;
        background-color: aqua;
        -webkit-transition: width 3s linear;
        -moz-transition: width 3s linear;
        transition: width 3s linear;
    }
</style>

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.