2

In CSS, I have a 1em square div:

.mydiv {
  width: 1em;
  height: 1em;
}

but since 1em = 15.4375px and height resolution must be different than width resolution, the square doesn't look really square but rectangular.

enter image description here

Anyone experienced this? Is there a way I can fix this? Maybe a CSS function that would round em in px?

3
  • pixel on a monitor aren't necessarily square en.wikipedia.org/wiki/… Apr 25, 2016 at 12:14
  • The appearance of an element on the screen depends on many things, not just width and height. You also have box-sizing, padding, margin, border, display, min-width, max-width etc! So can you show a more complete example that demonstrates the issue?
    – Mr Lister
    Apr 25, 2016 at 12:25
  • 1
    As to your actual question, the answer is no. You'll have to use JavaScript to round. Or, according to the answer to this question, LESS can do it too.
    – Mr Lister
    Apr 25, 2016 at 12:38

0

Your Answer

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

Browse other questions tagged or ask your own question.