Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reduce width and show scrollbar

Please see this page: you can see the same code snippet twice: once embedded via GitHub Gist and in the second part via Jekyll’s internal syntax highlighter Rouge.

I’m trying to style the second code snippet similar to the GitHub Gist. I’m making progress, but I don’t know how to reduce the width of the second code snippet via CSS. It should have the same width as the surrounding blog content (like the GitHub Gist) and show a horizontal scroll bar.

How can I reduce the width of the code snippet via CSS and display a horizontal scroll bar?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thx!

>Solution :

You can set the width to 100% to fill the surrounding blog content and use the overflow-x property to display a horizontal scroll bar.

.highlight {
    width: 100%;
    overflow-x: scroll;
}

You can use overflow-x: auto; instead of overflow-x: scroll; to let the browser decide when to display a horizontal scrollbar, e.g. when content is overflowing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading