{"id":23780969,"url":"https://github.com/rupok/css-tips","last_synced_at":"2026-02-25T21:32:27.622Z","repository":{"id":70447430,"uuid":"42928242","full_name":"rupok/css-tips","owner":"rupok","description":" A collection of tips to help take your CSS skills pro.","archived":false,"fork":false,"pushed_at":"2015-09-22T10:54:30.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-10T21:08:06.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rupok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-22T10:53:39.000Z","updated_at":"2015-09-22T10:53:39.000Z","dependencies_parsed_at":"2023-02-28T03:46:27.893Z","dependency_job_id":null,"html_url":"https://github.com/rupok/css-tips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rupok/css-tips","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupok%2Fcss-tips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupok%2Fcss-tips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupok%2Fcss-tips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupok%2Fcss-tips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rupok","download_url":"https://codeload.github.com/rupok/css-tips/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupok%2Fcss-tips/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29841592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T21:18:31.832Z","status":"ssl_error","status_checked_at":"2026-02-25T21:18:29.265Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-01T11:18:37.430Z","updated_at":"2026-02-25T21:32:27.596Z","avatar_url":"https://github.com/rupok.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSS Tips\n A collection of tips to help take your CSS skills pro.\n\n1. [Use `:not()` to Apply/Unapply Borders on Navigation](#use-not-to-applyunapply-borders-on-navigation)\n1. [Add Line-Height to `body`](#add-line-height-to-body)\n1. [Vertically Center Anything](#vertically-center-anything)\n1. [Select Items Using Negative `nth-child`](#select-items-using-negative-nth-child)\n1. [Use SVG for Icons](#use-svg-for-icons)\n1. [Inherit `box-sizing`](#inherit-box-sizing)\n1. [Get Rid of Margin Hacks With Flexbox](#get-rid-of-margin-hacks-with-flexbox)\n\n\n### Use `:not()` to Apply/Unapply Borders on Navigation\n\n```css\n/* instead of putting on the border... */\n.nav li {\n  border-right: 1px solid #666;\n}\n\n/* ...and then taking it off... */\n.nav li:last-child {\n  border-right: 0;\n}\n\n/* ...use :not() to only apply to the elements you want */\n.nav li:not(:last-child) {\n  border-right: 1px solid #666;\n}\n```\n\nIt's clean, readable, and easy to understand without the need for hack-y code.\n\n\n### Add Line-Height to `body`\n\n```css\nbody {\n  line-height: 1;\n}\n```\n\nYou don't need to add `line-height` to each `\u003cp\u003e`, `\u003ch*\u003e`, _et al_. separately. This way textual elements can inherit from `body` easily.\n\n\n### Vertically Center Anything\n\n```css\nhtml, body {\n  height: 100%;\n  margin: 0;\n}\n\nbody {\n  -webkit-align-items: center;  \n  -ms-flex-align: center;  \n  align-items: center;\n  display: -webkit-flex;\n  display: flex;\n}\n```\n\nNo, it's not dark magic, you really can center elements vertically. Look how simple this is.\n\n\n### Select Items Using Negative `nth-child`\n\n```css\nli {\n  display: none;\n}\n/* select items 1 through 3 and show them */\nli:nth-child(-n+3) {\n  display: block;\n}\n```\n\nUse negative `nth-child` in CSS to select items 1 through n. Well that was pretty easy.\n\n\n### Use SVG for Icons\n\n```css\n.logo {\n  background: url(\"logo.svg\");\n}\n```\n\nThere's no reason not to use SVG for icons. SVG is supported in all browsers back to IE9. So start ditching your .png, .jpg, or .gif-jif-whatev files.\n\n\n### Inherit `box-sizing`\n\n```css\nhtml {\n  box-sizing: border-box;\n}\n*, *:before, *:after {\n  box-sizing: inherit;\n}\n\n```\n\nLetting `box-sizing` be inheritted from `html` makes it easier to change `box-sizing` in plugins or other components that leverage other behavior.\n\n\n### Get Rid of Margin Hacks With Flexbox\n\n```css\n.list-of-people {\n  display: flex;\n  justify-content: space-between;\n}\n.list-of-people .person {\n  flex-basis: 23%;\n}\n```\n\nWhen working with column gutters you can get rid of `nth-`, `first-`, and `last-child` hacks by using flexbox's `space-between` property.\n\n\n### Support\n\nThese protips work in current versions of Chrome, Firefox, Safari, and Edge, and in IE11.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupok%2Fcss-tips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frupok%2Fcss-tips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupok%2Fcss-tips/lists"}