The prerequisite is that I use monospaced as a font family , but it doesn’t work properly, I tried some solution, work, my HTML structure looks like this:
<!DOCTYPE html> <style> body { font-family: monospace; letter-spacing: 0; word-spacing: 0; font-size: 32px; } div:last-of-type { padding-left: 1em; } </style> <div>123456</div> <div>abcdef</div>
use em
em should be equal to the value of the calculated font size , but padding-left: 1em; does not work:
use px
padding-left: 32px; draws the same conclusion as padding-left: 1em; .
use ex
ex must be the calculated height of the letter "x" , and it also does not work:
use ch
OK, webkit does not support ch as a css block.
So, how can I write css exactly by indenting the second div the width of one character , that is, the first "0" should be left-aligned to the letter "b", without any deviations.
source share