|
9 | 9 | <a name="position"></a> |
10 | 10 | ## Positioning |
11 | 11 |
|
12 | | -Elements are positioned relative to the scope element, so its top left corner is considered a (0, 0) point. GSS initialized upon `document`, `<html>`, `<body>` or `<head>` position against the `<html>` element. Global properties like `$left`, `$right`, `$scroll-top` and `$bottom` point to respective properties of `::window`. |
| 12 | +Elements are positioned relative to the scope element, so its top-left corner is considered a (0, 0) point. GSS initialized upon `document`, `<html>`, `<body>` or `<head>` position against the `<html>` element. Global properties like `$left`, `$right`, `$scroll-top` and `$bottom` point to respective properties of `::window`. |
13 | 13 |
|
14 | 14 | Cassowary is a general purpose solver, so it does not make any assumptions about the positioning or even geometry. If there's nothing that is bound to absolute values like zero or edges of the screen, the whole layout can be solved to be positioned off-screen. Negative `top` and `left` values is a common gotcha in *underconstrained* systems. |
15 | 15 |
|
|
91 | 91 | {% endhighlight %} |
92 | 92 |
|
93 | 93 | Position the `#someElm` top-left corner to be at 100px from the top-left of the page. |
94 | | -Same thing for `#otherElm` excepts its the top-right corner that's been position 200px |
| 94 | +Same thing for `#otherElm` except it's the top-right corner that's been positioned 200px |
95 | 95 | from the top-left of the page. |
96 | 96 |
|
97 | 97 | ### bottom-left, bottom-right |
|
102 | 102 | {% endhighlight %} |
103 | 103 |
|
104 | 104 | Position the `#someElm` bottom-left corner to be at 100px from the top-left of the page. |
105 | | -Same thing for `#otherElm`, excepts its the bottom-right corner that's been position 200px |
| 105 | +Same thing for `#otherElm`, except it's the bottom-right corner that's been positioned 200px |
106 | 106 | from the top-left of the page. |
107 | 107 |
|
108 | 108 | ### center-x, cx |
|
118 | 118 |
|
119 | 119 | {% endhighlight %} |
120 | 120 |
|
121 | | -Horizontally place the horizontal center of the element at 100px from the left of the page. |
| 121 | +Set the horizontal coordinate for the center of the element at 100px from the left of the page. |
122 | 122 |
|
123 | 123 | ### center-y, cy |
124 | 124 |
|
|
134 | 134 |
|
135 | 135 | {% endhighlight %} |
136 | 136 |
|
137 | | -Place the vertical center of the element 100px from the top of the page. |
| 137 | +Set the vertical coordinate for center of the element at 100px from the top of the page. |
138 | 138 |
|
139 | 139 | ### Center |
140 | 140 |
|
|
188 | 188 |
|
189 | 189 | By employing CSS to lay out big chunks of layout, we make each section solution independent. This leads to smaller individual constraint graphs and better overall performance. |
190 | 190 |
|
191 | | -With the `position: relative` declared in the `style` attribute, GSS will solve independently each sections which |
192 | | -should results in better performance. <a href="http://codepen.io/thegridgssdocs/pen/pvwaNN" target="_blank">Live example.</a> |
| 191 | +With the `position: relative` declared in the `style` attribute, GSS will solve independently each section which |
| 192 | +should result in better performance. <a href="http://codepen.io/thegridgssdocs/pen/pvwaNN" target="_blank">Live example.</a> |
193 | 193 |
|
194 | 194 | ## Dimensions |
195 | | -GSS provides property to constrain the dimension of an element. We've already saw the `width` and `height`. |
| 195 | +GSS provides a property to constrain the dimension of an element. We already saw the `width` and `height` properties. |
196 | 196 | GSS provides syntax sugar called 2d properties to constrain both height and width of an element as a single property. |
197 | 197 |
|
198 | 198 | {% highlight css %} |
|
205 | 205 |
|
206 | 206 | ## Intrinsic values |
207 | 207 |
|
208 | | -Positioning elements with `top` and `left` properties doesn't require GSS to know the dimensions of that elements. But `right` and `bottom` properties need to know about `width` and `height` of the element respectively. Properly constrained system will provide those values indirectly with no regard to elements contents. |
| 208 | +Positioning elements with `top` and `left` properties doesn't require GSS to know the dimensions of those elements. But `right` and `bottom` properties need to know about `width` and `height` of the element respectively. Properly constrained systems will provide those values indirectly with no regard to an element's contents. |
209 | 209 |
|
210 | | -However it's often desirable to know the computed dimensions of specific elements which GSS has no control over - be it text, images or blocks styled with CSS. Measurements provide dynamic "islands" to the layout, which can be automatically recomputed, whenever measured things are updated from the outside. It also may act as a feedback to the solver, disallowing content to shrink too much or helping to decide if things fit. |
| 210 | +However, it's often desirable to know the computed dimensions of specific elements which GSS has no control over - be it text, images or blocks styled with CSS. Measurements provide dynamic "islands" to the layout, which can be automatically recomputed, whenever measured things are updated from the outside. It also may act as a feedback to the solver, disallowing content to shrink too much or helping to decide if things fit. |
211 | 211 |
|
212 | | -Prepending property with `intrinsic-` or `computed-` prefix makes GSS measure the values. |
| 212 | +Prefixing a property with `intrinsic-` or `computed-` prefix makes GSS measure the value. |
213 | 213 |
|
214 | | -Using `intrinsic` property is used on the element, makes the property to be *read-only*. Declaration of `intrinsic-width` [propertywill ensure that `width` style is never applied to that element. This allows dimensions to change and update naturally. Otherwise, the width would be computed and applied only the first time, making it static. |
| 214 | +Prefixing a property with `intrinsic-` makes it *read-only* and it won't apply on the element. For example, declaring `intrinsic-width` will ensure that the `width` style is never applied to that element. This allows dimensions to change and update naturally. Otherwise, the width would be computed and applied only the first time, making it static. |
215 | 215 |
|
216 | | -`computed` properties can be used to measure styles regardless of their origin - either GSS constraints or CSS styles. Computed properties will not make styles *read-only*, unlike intrinsic properties. |
| 216 | +`computed`-prefixed properties can be used to measure styles regardless of their origin - either GSS constraints or CSS styles. Computed properties will not make styles *read-only*, unlike `intrinsic`-prefixed properties. |
217 | 217 |
|
218 | 218 | {% highlight css %} |
219 | 219 |
|
220 | | - // apply static width, measure height |
221 | | - // (height style will not be set) |
222 | | - .selectorA { |
223 | | - width: == 200; |
224 | | - height: == &intrinsic-height; |
225 | | - } |
| 220 | +// apply static width, measure height |
| 221 | +// (height style will not be set) |
| 222 | +.selectorA { |
| 223 | + width: == 200; |
| 224 | + height: == &intrinsic-height; |
| 225 | +} |
226 | 226 |
|
227 | | - // only measure dimensions |
228 | | - // (height & width styles will not be set) |
229 | | - .selectorB { |
230 | | - width: == &intrinsic-width; |
231 | | - height: == &intrinsic-height; |
232 | | - } |
| 227 | +// only measure dimensions |
| 228 | +// (height & width styles will not be set) |
| 229 | +.selectorB { |
| 230 | + width: == &intrinsic-width; |
| 231 | + height: == &intrinsic-height; |
| 232 | +} |
233 | 233 |
|
234 | | - // use dimension information to position elements |
235 | | - .selectorA[right] == .selectorB[left]; |
| 234 | +// use dimension information to position elements |
| 235 | +.selectorA[right] == .selectorB[left]; |
236 | 236 |
|
237 | 237 | {% endhighlight %} |
238 | 238 |
|
|
241 | 241 |
|
242 | 242 | Learn how to use [CCSS constraints](/guides/ccss) |
243 | 243 |
|
244 | | -GSS provides conditionnal statements to allow you to do responsive design. Read our [@if @else guide](/guides/ifelse) to learn more. |
| 244 | +GSS provides conditional statements to allow you to do responsive design. Read our [@if @else guide](/guides/ifelse) to learn more. |
245 | 245 |
|
246 | 246 | With only CCSS constraints at your disposal, constraining common layout scenarios quickly becomes tedious. Read our |
247 | 247 | [VFL guide](/guides/ifelse) to learn how to more efficiently constrain your layout. |
0 commit comments