Skip to content

Commit 744d4b2

Browse files
committed
Use more robust way of removing whitespace.
As per this Tweet by @thierryk: https://twitter.com/thierrykoblentz/status/305152267374428160 A change introduced in Chrome 25 breaks the previously used method of removing whitespace. This update to csswizardry-grids uses a far more robust method, but this commit can be picked back out if the Chrome dev team revert their changes.
1 parent 688ede6 commit 744d4b2

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* 1.0.0 Initial release
22
* 1.0.1 Make base grid classes follow silencing rules
3+
* 1.1 Use more robust, markup-based method for removing whitespace

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ like this:
3636

3737
<div class="grid__item one-whole lap-one-half desk-two-thirds">
3838
...
39-
</div>
39+
</div><!--
4040

41-
<div class="grid__item one-whole lap-one-half desk-one-third">
41+
--><div class="grid__item one-whole lap-one-half desk-one-third">
4242
...
4343
</div>
4444

@@ -50,9 +50,9 @@ If you are using silent classes then your HTML might look like this:
5050

5151
<div class="content">
5252
...
53-
</div>
53+
</div><!--
5454

55-
<div class="sub-content">
55+
--><div class="sub-content">
5656
...
5757
</div>
5858

@@ -79,6 +79,12 @@ If you are using silent classes then your HTML might look like this:
7979
@extend %desk-one-third;
8080
}
8181

82+
The empty HTML comments are to remove whitespace caused by using `inline-block`.
83+
Prior to v1.1 this was tackled by using some
84+
[`[letter|word]-spacing` trickery](https://github.com/csswizardry/csswizardry-grids/blob/60a5075ac65282bb24fa5a5d5ed32a060ce2975f/csswizardry-grids.scss#L64-L65),
85+
however Chrome 25 introduced a change which meant this method now broke
86+
csswizardry-grids.
87+
8288
## Demo
8389

8490
There is a very simple demo which can be found at

csswizardry-grids.scss

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,28 @@ $class-type: unquote(".");
5454
* 1. Allow the grid system to be used on lists.
5555
* 2. Remove any margins and paddings that might affect the grid system.
5656
* 3. Apply a negative `margin-left` to negate the columns’ gutters.
57-
* 4. Remove whitespace caused by `inline-block` elements.
5857
*/
5958
#{$class-type}grid{
6059
list-style:none; /* [1] */
6160
margin:0; /* [2] */
6261
padding:0; /* [2] */
6362
margin-left:-$gutter; /* [3] */
64-
letter-spacing:-0.31em; /* [4] */
65-
word-spacing:-0.43em; /* [4] */
6663
}
6764

6865

6966
/**
7067
* 1. Cause columns to stack side-by-side.
7168
* 2. Space columns apart.
7269
* 3. Align columns to the tops of each other.
73-
* 4. Reinstate removed whitespace.
74-
* 5. Required to combine fluid widths and fixed gutters.
70+
* 4. Required to combine fluid widths and fixed gutters.
7571
*/
7672
#{$class-type}grid__item{
7773
display:inline-block; /* [1] */
7874
padding-left:$gutter; /* [2] */
7975
vertical-align:top; /* [3] */
80-
letter-spacing:normal; /* [4] */
81-
word-spacing:normal; /* [4] */
82-
-webkit-box-sizing:border-box; /* [5] */
83-
-moz-box-sizing:border-box; /* [5] */
84-
box-sizing:border-box; /* [5] */
76+
-webkit-box-sizing:border-box; /* [4] */
77+
-moz-box-sizing:border-box; /* [4] */
78+
box-sizing:border-box; /* [4] */
8579
}
8680

8781

0 commit comments

Comments
 (0)