simple.css icon indicating copy to clipboard operation
simple.css copied to clipboard

Fix table ignoring width

Open farooqaaa opened this issue 3 years ago • 2 comments

With display: block, a table doesn't stretch to the whole box. CSS width property is completely ignored if it's a block.

farooqaaa avatar Aug 10 '22 13:08 farooqaaa

Deploy Preview for simplecss-cdn ready!

Name Link
Latest commit 867b9fa9d473c03b81e08cf0c0c1377bd64f594f
Latest deploy log https://app.netlify.com/sites/simplecss-cdn/deploys/6402a70d5baa440008b7298f
Deploy Preview https://deploy-preview-104--simplecss-cdn.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Aug 10 '22 13:08 netlify[bot]

I'm not happy with the way we style tables right now, as there's accessibility concerns with setting display: block on <table>, but then we get overflowing tables, like the screenshot below with your change:

Gc35fvNG

I think the best fix while still having scrolling tables when too large would be to merge your change (display: table, as Bob intended) and have users wrap their tables in <figure> elements—but this approach would be a breaking change, so I think we should postpone this until the next minor version (and write the appropriate documentation).

lkhrs avatar Aug 10 '22 15:08 lkhrs

Would using display:table; and wrapping the table inside a div work? That should stop it scrolling, right?

kevquirk avatar Feb 18 '23 16:02 kevquirk

Would using display:table; and wrapping the table inside a div work? That should stop it scrolling, right?

Yes, that will stop the table itself from scrolling. Then you'd set overflow-x: scroll on the <div> or <figure>.

lkhrs avatar Feb 19 '23 23:02 lkhrs

More thoughts on this: I'm debating which element would make more sense: <div> or <figure>. I think <div> would result in unwanted scrolling, while <figure> is more deliberate. <figure> is also the pattern used by pico.css.

lkhrs avatar Feb 22 '23 16:02 lkhrs

I've just tested it (quickly, and only on Safari) and both div and figure appear to display in the same way - they scroll off screen with a scroll bar.. I'm happy to go either way, personally. Ultimately, it's only for the demo, folk who use it can decide how best they would like to use a table on their project.

kevquirk avatar Feb 22 '23 17:02 kevquirk

Went with figure as the horizontal scrolling utility element. Initially tried :has but unfortunately it's too new, and Gecko is lagging behind on implementation.

Pending merge, I'll update the docs with the new utility.

Thoughts?

lkhrs avatar Mar 04 '23 02:03 lkhrs

Merged 😊

kevquirk avatar Mar 08 '23 06:03 kevquirk