Fill Background color from Right to left CSS

I am trying to do a background color transition but have been stuck.

My goal is when a button is clicked, I want to transition a linear gradient background that is half red on the left side and half blue on the right side to slide left and become full blue.

I have attempted it in this jfiddle but I am not sure what I am doing wrong. Any help would be appreciated. Thank you!

https://jsfiddle.net/8Lbw23rt/

HTML code:

<div class="colorChange">
        <p>test</p>
</div>

<button class="test-button" id="test" type="button">Change Color!</button>

CSS Code:

.colorChange {
  width:150px;
  height: 150px;
  padding: 11px 16px;
  text-align:center;
  float:left;
  background: linear-gradient(to right, red 50%, blue 50%);
  background-size: 100% 100%;
  background-position:left bottom;
  margin-left:10px;
  transition:all 2s ease;
  margin-right: 50px;
}

.test-button {
  height: 50px;
  width: 100px;
}

JS Code:

$(function() {
    $('#test').on('click', function() {
        $('.colorChange').css('background-position', 'right bottom');
    })
})

159 thoughts on “Fill Background color from Right to left CSS”

  1. Pingback: plaquenil canada
  2. Pingback: ivermect 6
  3. Pingback: sildenafil citrate
  4. Pingback: viagra buy online
  5. Pingback: viagra cialis
  6. Pingback: viagra sale
  7. Pingback: cialis for sale
  8. Pingback: lilly cialis 5mg
  9. Pingback: cialis daily
  10. Pingback: cialis online
  11. Pingback: cvs stromectol
  12. Pingback: sildenafil
  13. Pingback: viagra cheap
  14. Pingback: hims viagra
  15. Pingback: viagra otc
  16. Pingback: viagra para mujer
  17. Pingback: cost of viagra
  18. Pingback: viagra price
  19. Pingback: cost for viagra
  20. Pingback: low price viagra
  21. Pingback: viagra tablet
  22. Pingback: female viagra
  23. Pingback: buy viagra
  24. Pingback: goodrx sildenafil

Leave a Comment