Skip to content

Instantly share code, notes, and snippets.

@potch
Created September 26, 2011 18:53
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save potch/1243028 to your computer and use it in GitHub Desktop.
Save potch/1243028 to your computer and use it in GitHub Desktop.
CSS to add line numbers to embedded gists
.gist-highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist-highlight pre {
counter-reset: linenumbers;
}
.gist-highlight pre div:before {
color: #aaa;
content: counter(linenumbers);
counter-increment: linenumbers;
left: -3ex;
position: absolute;
text-align: right;
width: 2.5ex;
}
@dmackerman
Copy link

Good one!

@danriti
Copy link

danriti commented Jan 25, 2012

amazing!

@chriseldredge
Copy link

Add this to the last selector to prevent line numbers from being selected during copy/paste operations:

    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

Via http://stackoverflow.com/questions/826782/css-rule-to-disable-text-selection-highlighting

@mewdriller
Copy link

👍

@yyl
Copy link

yyl commented Jun 24, 2012

Nice job!

@revathskumar
Copy link

Great Hack... Thankz
@chriseldredge A special thankz for you too.....

@flavioribeiro
Copy link

wow!

@aorcsik
Copy link

aorcsik commented Sep 23, 2012

Really nics, thx :)

@oraculum
Copy link

oraculum commented Nov 1, 2012

now is correct:

.gist .gist-highlight {
border-left: 3ex solid #eee;
position: relative;
}

.gist .gist-highlight pre {
counter-reset: linenumbers;
}

.gist .gist-highlight pre div:before {
color: #aaa;
content: counter(linenumbers);
counter-increment: linenumbers;
left: -3ex;
position: absolute;
text-align: right;
width: 2.5ex;
}

@dhust
Copy link

dhust commented Jan 6, 2014

Doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment