GithubHelp home page GithubHelp logo

andrewh0 / okcss Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 4.0 214 KB

πŸ†— Sensible styling defaults for your web page

Home Page: https://okcss.netlify.app

License: MIT License

HTML 51.94% JavaScript 1.17% CSS 46.89%
css classless-css

okcss's Introduction

πŸ†— OK.css

Sensible styling defaults for your web page

Project page Β· Demo


OK.css is a classless CSS framework. Dropping it into your HTML will make your page look decent β€” no need to reference documentation, think about responsiveness, or account for browser differences as long as your markup is semantically-correct.

To use it, you can download the CSS file directly or add the following line to your HTML <head>:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@1/dist/ok.min.css" />

Note that normalize.css is included in OK.css.

OK.css is somewhere between a CSS normalizer and a full-fledged framework like Bootstrap or Tailwind. It's great for blogs or small single-page applications, but might not be so great for large, interactive apps that require JavaScript or custom elements.

Development

Install dependencies with yarn install.

You can start a local server with yarn start. By default, the page will be available at http://localhost:5000.

Make updates to the CSS file in ./src/ok.css and yarn build to create a minified version available in ./dist/ok.min.css.

This repo is set up with Netlify's continuous deployment. yarn deploy copies files into a .gitignored directory called _site and _site is hosted on Netlify.

Releasing

Confirm changes with:

yarn release:dry

Release with:

yarn release

Contributing

Pull requests are welcome! If you find a bug or have a feature request, please submit a GitHub issue.

Alternative features

Not all UI features can be implemented with classless CSS while remaining accessible and supported cross-browser. For more complex features, you may need to supplement this framework with additional HTML, CSS, or JavaScript.

Here are some suggestions for altering the behavior of certain elements.

Feature

Make tables scroll horizontally when they are wider than the main content width.

Desired behavior:

HTML table with horizontal scroll

Note: In OK.css, tables are set to display: table for accessibility reasons.

Implementation

Wrap the table in a <div> with overflow-x: scroll;:

<div style="overflow-x: scroll">
  <table>
  ...
  </table>
</div>

One caveat is that this can prevent the table heading from sticking when scrolling vertically.

okcss's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

okcss's Issues

Make `<table />` header sticky, update `<table/>` to `display: table`

Chrome v91 allows table headers to stick to the top of the table. This allows for better readability if the table is tall.

https://twitter.com/chriscoyier/status/1400897989842030593
Example: https://codepen.io/chriscoyier/pen/WNpJewq

Also, table should be display: table, not display: block for accessibility reasons. Source

Changing the display value of a <table> element to block, grid, or flex will alter its representation in the accessibility tree. This will cause the table to no longer be announced properly by screen reading technology.

use overflow-x on tables?

You've done a really nice job on this framework. The only problem I've found is wide tables become very compressed on small phones in portrait mode. Have you considered changing the table's "width: 100%" attribute to "display:block; overlow-x: scroll"?

Description list (dl/dt/dd) spacing bug + general (mostly delighted) feedback :)

Hi @andrewh0,

I came here from https://github.com/dohliam/dropin-minimal-css β€” okcss is my top favorite across the whole list. So expectations to find "something ok" have definitely been exceeded! πŸ˜ƒ How can this be 1 star before me only?! πŸ€”

Before I spam you with multiple GitHub tickets unasked, let me combine one likely bug and general feedback (below) in one ticket here for a start β€” I'm happy to split more issues off, if desired.

I think the styling of <dl>/<dt>/<dd> is broken with regard to spacing, this doesn't look right:

okcss_bug_dl

With this (likely sub-optimal) workaround of mine…

dt {
    margin-bottom: 0;
}

dl dt:nth-child(1n+2) {
    margin-top: 1.5ex;
}

…I get things to this state:

okcss_good_dl

What do you think about this issue and direction for a fix?

Other small things I noticed:

  • Visual:
    • The overall "page width" is a bit too narrow for big screens. I think what Boostrap's class container does may be a better default, but it would need a closer look. Is the current width considered a key feature?
  • Non-visual:
    • The readme could mention dependency normalize.css in particular, not just normalization in general. I was surprised to find normalize.css bundled under the hood after reading that text.
    • It would be nice to have a version in ok.min.css like ok-1.2.3.min.css for easy identification and support for a non-moving target. I will likely put it inside a Git repo without using a CDN and for that scenario the version would be great.
    • Dist file ok.min.css file mentions normalize.css and its license inside, but does not mention okcss, its version and license. That would be nice.
    • (Have you tried putting :ok:/:ok: at the start of the GitHub repo description? I think it would look nice.)

What do you think?

Best, Sebastian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.