File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
10
10
For a steady stream of TILs from a variety of rocketeers, checkout
11
11
[ til.hashrocket.com] ( https://til.hashrocket.com/ ) .
12
12
13
- _ 717 TILs and counting..._
13
+ _ 718 TILs and counting..._
14
14
15
15
---
16
16
@@ -94,6 +94,7 @@ _717 TILs and counting..._
94
94
- [ Dry Up SCSS With Mixins] ( css/dry-up-scss-with-mixins.md )
95
95
- [ Lighten And Darken With CSS Brightness Filter] ( css/lighten-and-darken-with-css-brightness-filter.md )
96
96
- [ Lighten And Darken With SCSS] ( css/lighten-and-darken-with-scss.md )
97
+ - [ Make A Block Of Text Respect New Lines] ( css/make-a-block-of-text-respect-new-lines.md )
97
98
- [ Parameterized SCSS Mixins] ( css/parameterized-scss-mixins.md )
98
99
99
100
### Devops
Original file line number Diff line number Diff line change
1
+ # Make A Block Of Text Respect New Lines
2
+
3
+ Generally when we fill a ` div ` tag full of text, it will display it one long
4
+ strand irrespective of any line breaks that are included. This is a great
5
+ default, but not necessarily what we want when we are displaying text from
6
+ another source, such as our users.
7
+
8
+ We can convince a block of text to respect new lines by adding a couple CSS
9
+ properties.
10
+
11
+ ``` css
12
+ .multiline-text {
13
+ word-wrap : break-word ;
14
+ white-space : pre-line ;
15
+ }
16
+ ```
17
+
18
+ The first rule, ` word-wrap: break-word ` , ensures that long lines of text
19
+ uninterrupted by new lines respect the boundaries of our wrapping element.
20
+ The second rule, ` white-space: pre-line ` , handles squashing of extra white
21
+ space and respecting of new lines.
22
+
23
+ See a [ working example here] ( https://codepen.io/anon/pen/bQpKyv ) .
You can’t perform that action at this time.
0 commit comments