In my html / css application, I have the concept of a button, which is essentially a .button class with a bunch of related attributes. Here's a simplified example:
.button { width: 120px; height: 30px; line-height: 30px; background: yellow; text-align: center; }
<div class="button"> <div class="button-text"> Button text </div> </div>
In a small number of places, the text to be displayed is quite long, but it should still be fully consistent. Since the font-stretch property does not support, I use transform: scale , which does what I need - the view ... In addition to the above, I have:
.button { width: 120px; height: 30px; line-height: 30px; background: yellow; text-align: center; } .button-text { line-height: 30px; transform: scale(0.7, 1); white-space: nowrap; }
<div class="button"> <div class="button-text"> Very long button text </div> </div>
Now the text is suitable, but not centered, because the position with the content center in the DIV is calculated before the conversion is applied - see the example in this jsfiddle: https://jsfiddle.net/1xz1g634/1/
I can βmakeβ it centered by applying a negative left margin to .button-text , however, that the hack and margin should be different in different browsers.
How can I damage this text? Ideally, without resorting to javascript, but if all else fails, I can use javascript / jquery.
source share