I believe that you are really looking for the final state to fill the entire element with background color and not leave a space. You can also do this with linear-gradient background images and translate their background-size and background-position , as in the snippet below.
One of the drawbacks of using linear-gradient over pseudo-elements or transformations is that browser support is lower, but additional pseudo-elements are not needed for this, and therefore they can leave them spare for other uses.
.button_sliding_bg { color: #31302B; background: #FFF; padding: 12px 17px; margin: 25px; font-family: 'OpenSansBold', sans-serif; border: 3px solid #31302B; font-size: 14px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; border-radius: 2px; display: inline-block; text-align: center; cursor: pointer; background-image: linear-gradient(135deg, #31302B 50%, transparent 51%); background-size: 100px 100px; background-position: -50px -50px; background-repeat: no-repeat; transition: all ease 0.8s; } .button_sliding_bg:hover { background-size: 200% 200%; background-position: 0px 0px; color: #FFF; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <button class="button_sliding_bg">Buttontext</button> <button class="button_sliding_bg">Button text lengthy</button> <button class="button_sliding_bg">Button text <br> with line break</button> <button class="button_sliding_bg">Button text <br> with <br> multiple <br> line <br>breaks</button>
Harry source share