I mentioned a simple CSS trick to generate full-width figures in 2021. I was thinking the other day if I could make certainly elements automatic, so I do not need to manually specify them to be full-width. Finally, I wrote some JS code to deal with three types of elements automatically:

  1. Code blocks (<pre><code>).

    If the scrollWidth is greater than offsetWidth, it means the code block has a horizontal …