Skip to content

Instantly share code, notes, and snippets.

View nicohaemhouts's full-sized avatar

Nico Haemhouts nicohaemhouts

  • Sydney, Australia
View GitHub Profile

Dropcap

Show the first letter of the first paragraph larger and in a different color than the rest of the text, using the ::first-letter selector.

A Pen by Nico Haemhouts on CodePen.

License.

@nicohaemhouts
nicohaemhouts / Limit-the-number-of-lines-in-a-textarea.markdown
Last active March 18, 2024 22:01
Limit the number of lines in a textarea

Limit the number of lines in a textarea

This limits the number of lines of any textarea that has the attribute 'data-limit-rows' set to 'true'. The limit is the 'rows'-attribute of the textarea.

To know how many lines have been entered you have to look at the number of newline characters (\n) in the text. You could do this by splitting text on the newline character, and looking at the length of the resulting array: i.e. myText.split(/\n/g).length; This would work fine in every browser, except for one special case in Internet Explorer 8, whereby the user hits the enter key several times in a row, thus producing empty lines. In this case Internet Explorer 8 excludes all empty values from the resulting array, ie those places where the delimiters appear next to each other. The result is that the usr can enter more lines of text than permitted. This is probably also true for Internet Explorer versions lower than 8, but I didn't check.

To know which key was pressed it's b

@nicohaemhouts
nicohaemhouts / Pasting-multi-line-text-into-a-single-line-text-input-in-Internet-Explorer.markdown
Created March 23, 2015 11:45
Pasting multi-line text into a single-line text input in Internet Explorer

Pasting multi-line text into a single-line text input in Internet Explorer

When you paste multi-line text into a single-line text input in Internet Explorer you only get the first line. This is because IE chucks away everything after the first newline-character. Other browsers will simply replace the newline with spaces. This snippet does the same thing for IE. If window.clipboardData exists we're on IE and we should intercept the paste event to replace newlines with spaces.

A Pen by Nico Haemhouts on CodePen.

License.

@nicohaemhouts
nicohaemhouts / Affix-and-stack-elements-at-the-top-of-the-screen-on-scroll..markdown
Created March 25, 2015 14:06
Affix and stack elements at the top of the screen on scroll.

Affix and stack elements at the top of the screen on scroll.

Kind of like the affix plugin in Twitter Bootstrap, but this one automatically calculates the top offset. It creates a nice stack of elements under the fixed navbar at the top of the screen.

A Pen by Nico Haemhouts on CodePen.

License.

body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
@nicohaemhouts
nicohaemhouts / _.md
Last active August 29, 2015 14:24
CDS EventsPerSecond
@nicohaemhouts
nicohaemhouts / _.md
Last active August 29, 2015 14:24
CDS EventsPerSecond 2
@nicohaemhouts
nicohaemhouts / _.md
Last active August 29, 2015 14:24
Force Layout NGS
@nicohaemhouts
nicohaemhouts / _.md
Last active August 29, 2015 14:24
Force Layout NGS 2
@nicohaemhouts
nicohaemhouts / _.md
Created July 13, 2015 10:51
Progres Arc