Skip to content

Flexible Height Explanation #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ A collection of tips to help take your CSS skills pro.
1. [Equal Width Table Cells](#equal-width-table-cells)
1. [Get Rid of Margin Hacks With Flexbox](#get-rid-of-margin-hacks-with-flexbox)
1. [Use Attribute Selectors with Empty Links](#use-attribute-selectors-with-empty-links)
1. [Style "Default" Links](#style-default-links)
1. [Style "Default" Links](#style-default-links)
1. [Use % height on elements](#percent-height)


### Use `:not()` to Apply/Unapply Borders on Navigation
Expand Down Expand Up @@ -254,7 +255,22 @@ a[href]:not([class]) {

Now links that are inserted via a CMS, which don't usually have a `class` attribute, will have a distinction without generically affecting the cascade.

### Percent Height

For apply a flexible height (in percent) to a element in HTML, you need that a parent element have a **fixed** height, something like:

```css
.my-outer-element {
height : 100px
}

.my-outer-element > .my-inner-element {
height : 50%
}
```

Now we have `.my-outer-element` with **100px** of height, and a `.my-inner-element` that will have **50%** of the parent element height, so **50px**.

### Support

These protips work in current versions of Chrome, Firefox, Safari, and Edge, and in IE11.
These protips work in current versions of Chrome, Firefox, Safari, and Edge, and in IE11.