How to prevent Chrome from flickering when using width transitions?









up vote
0
down vote

favorite












I have a website that is written from right to left, and I would like to create a custom progress bar (using nested <div> elements, rather than the <progress> element).



My basic HTML file looks like this (I have included the CSS and the JavaScript in the same file):






<!doctype html>
<html dir="rtl">
<head>
<title>Flickering issue</title>
<style>

body
margin: 20px;
direction: rtl;


#container
width: 50%;
height: 13px;
border: 1px solid rgba(0, 0, 0, .1);
background: rgba(0, 0, 0, .05);


#progress
width: 0;
height: 100%;
transition: width 800ms;
background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


</style>
</head>
<body>

<div id="container">
<div id="progress"></div>
</div>

<script>

var progress = document.getElementById("progress"),
curWidth = 0,
interval = setInterval(updateWidth, 1500);

function updateWidth()
progress.style.width = (curWidth += 4) + "%";
if (curWidth >= 100)
clearInterval(interval);



</script>

</body>
</html>





In Chrome, the right edge of the progress bar flickers whenever the width is updated, and it's really ugly and annoying. This issue does not happen in Firefox.



I've looked for similar issues online, and noticed this is a common problem in Chrome. However, none of the solutions I've found helped solve my issue.



I've tried the following CSS rules:



backface-visibility: hidden !important;

transform: translateZ(0) scale(1,1) !important;

transform-style: preserve-3d !important;


, but nothing changes...



Thanks in advance for any help.










share|improve this question

























    up vote
    0
    down vote

    favorite












    I have a website that is written from right to left, and I would like to create a custom progress bar (using nested <div> elements, rather than the <progress> element).



    My basic HTML file looks like this (I have included the CSS and the JavaScript in the same file):






    <!doctype html>
    <html dir="rtl">
    <head>
    <title>Flickering issue</title>
    <style>

    body
    margin: 20px;
    direction: rtl;


    #container
    width: 50%;
    height: 13px;
    border: 1px solid rgba(0, 0, 0, .1);
    background: rgba(0, 0, 0, .05);


    #progress
    width: 0;
    height: 100%;
    transition: width 800ms;
    background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


    </style>
    </head>
    <body>

    <div id="container">
    <div id="progress"></div>
    </div>

    <script>

    var progress = document.getElementById("progress"),
    curWidth = 0,
    interval = setInterval(updateWidth, 1500);

    function updateWidth()
    progress.style.width = (curWidth += 4) + "%";
    if (curWidth >= 100)
    clearInterval(interval);



    </script>

    </body>
    </html>





    In Chrome, the right edge of the progress bar flickers whenever the width is updated, and it's really ugly and annoying. This issue does not happen in Firefox.



    I've looked for similar issues online, and noticed this is a common problem in Chrome. However, none of the solutions I've found helped solve my issue.



    I've tried the following CSS rules:



    backface-visibility: hidden !important;

    transform: translateZ(0) scale(1,1) !important;

    transform-style: preserve-3d !important;


    , but nothing changes...



    Thanks in advance for any help.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a website that is written from right to left, and I would like to create a custom progress bar (using nested <div> elements, rather than the <progress> element).



      My basic HTML file looks like this (I have included the CSS and the JavaScript in the same file):






      <!doctype html>
      <html dir="rtl">
      <head>
      <title>Flickering issue</title>
      <style>

      body
      margin: 20px;
      direction: rtl;


      #container
      width: 50%;
      height: 13px;
      border: 1px solid rgba(0, 0, 0, .1);
      background: rgba(0, 0, 0, .05);


      #progress
      width: 0;
      height: 100%;
      transition: width 800ms;
      background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


      </style>
      </head>
      <body>

      <div id="container">
      <div id="progress"></div>
      </div>

      <script>

      var progress = document.getElementById("progress"),
      curWidth = 0,
      interval = setInterval(updateWidth, 1500);

      function updateWidth()
      progress.style.width = (curWidth += 4) + "%";
      if (curWidth >= 100)
      clearInterval(interval);



      </script>

      </body>
      </html>





      In Chrome, the right edge of the progress bar flickers whenever the width is updated, and it's really ugly and annoying. This issue does not happen in Firefox.



      I've looked for similar issues online, and noticed this is a common problem in Chrome. However, none of the solutions I've found helped solve my issue.



      I've tried the following CSS rules:



      backface-visibility: hidden !important;

      transform: translateZ(0) scale(1,1) !important;

      transform-style: preserve-3d !important;


      , but nothing changes...



      Thanks in advance for any help.










      share|improve this question













      I have a website that is written from right to left, and I would like to create a custom progress bar (using nested <div> elements, rather than the <progress> element).



      My basic HTML file looks like this (I have included the CSS and the JavaScript in the same file):






      <!doctype html>
      <html dir="rtl">
      <head>
      <title>Flickering issue</title>
      <style>

      body
      margin: 20px;
      direction: rtl;


      #container
      width: 50%;
      height: 13px;
      border: 1px solid rgba(0, 0, 0, .1);
      background: rgba(0, 0, 0, .05);


      #progress
      width: 0;
      height: 100%;
      transition: width 800ms;
      background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


      </style>
      </head>
      <body>

      <div id="container">
      <div id="progress"></div>
      </div>

      <script>

      var progress = document.getElementById("progress"),
      curWidth = 0,
      interval = setInterval(updateWidth, 1500);

      function updateWidth()
      progress.style.width = (curWidth += 4) + "%";
      if (curWidth >= 100)
      clearInterval(interval);



      </script>

      </body>
      </html>





      In Chrome, the right edge of the progress bar flickers whenever the width is updated, and it's really ugly and annoying. This issue does not happen in Firefox.



      I've looked for similar issues online, and noticed this is a common problem in Chrome. However, none of the solutions I've found helped solve my issue.



      I've tried the following CSS rules:



      backface-visibility: hidden !important;

      transform: translateZ(0) scale(1,1) !important;

      transform-style: preserve-3d !important;


      , but nothing changes...



      Thanks in advance for any help.






      <!doctype html>
      <html dir="rtl">
      <head>
      <title>Flickering issue</title>
      <style>

      body
      margin: 20px;
      direction: rtl;


      #container
      width: 50%;
      height: 13px;
      border: 1px solid rgba(0, 0, 0, .1);
      background: rgba(0, 0, 0, .05);


      #progress
      width: 0;
      height: 100%;
      transition: width 800ms;
      background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


      </style>
      </head>
      <body>

      <div id="container">
      <div id="progress"></div>
      </div>

      <script>

      var progress = document.getElementById("progress"),
      curWidth = 0,
      interval = setInterval(updateWidth, 1500);

      function updateWidth()
      progress.style.width = (curWidth += 4) + "%";
      if (curWidth >= 100)
      clearInterval(interval);



      </script>

      </body>
      </html>





      <!doctype html>
      <html dir="rtl">
      <head>
      <title>Flickering issue</title>
      <style>

      body
      margin: 20px;
      direction: rtl;


      #container
      width: 50%;
      height: 13px;
      border: 1px solid rgba(0, 0, 0, .1);
      background: rgba(0, 0, 0, .05);


      #progress
      width: 0;
      height: 100%;
      transition: width 800ms;
      background: linear-gradient(to left, rgb(0, 160, 0), rgb(0, 200, 0), rgb(0, 235, 0));


      </style>
      </head>
      <body>

      <div id="container">
      <div id="progress"></div>
      </div>

      <script>

      var progress = document.getElementById("progress"),
      curWidth = 0,
      interval = setInterval(updateWidth, 1500);

      function updateWidth()
      progress.style.width = (curWidth += 4) + "%";
      if (curWidth >= 100)
      clearInterval(interval);



      </script>

      </body>
      </html>






      css google-chrome width css-transitions progress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 20:01









      Guy

      83




      83



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252682%2fhow-to-prevent-chrome-from-flickering-when-using-width-transitions%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252682%2fhow-to-prevent-chrome-from-flickering-when-using-width-transitions%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3