Styling sample code

 I added a 'div' with 'overflow: auto, max-width: 100%' around the sample code in my tips page to avoid a warning in 'Lighthouse' about the content not being sized correctly for the viewport on a mobile.


If a line of code is longer than the width of the browser, this means a scrollbar appears below the code. This keeps the content within the width of the browser.


You can put the 'overflow' CSS on the 'code' or 'pre' tags if these tags enclose all your sample code.


I also say 'contenteditable="true" spellcheck="false"' on the 'div' so the code can be easily selected and the browser does not underline in red what it thinks is misspelt.


There is lots more to styling sample code like colour syntax highlighting, shadows, slight rotation, and different typefaces.


There are more tips at: bbingo.xyz/t

Comments

Popular posts from this blog

webkit-tap-highlight-color in CSS

Steve Jobs quotes