How to create a responsive HTML table

How to create a responsive HTML table

Kevin Powell

1 год назад

229,647 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@i3looi2
@i3looi2 - 26.07.2023 13:08

what i like to do on small sizes is to split (visually) the table rows, so they transform from table rows to self contained blocks/entities from a UI perspective

Ответить
@MmmMmmGood17
@MmmMmmGood17 - 10.08.2023 03:55

I was thinking you were going to do a sticky header and a sticky first column.. that way you could scroll the content inside without losing context of the headers and first column…

Ответить
@lmd4881
@lmd4881 - 14.08.2023 20:47

as always its fantastic!! :)

Ответить
@derbohmann
@derbohmann - 23.08.2023 23:24

You get a like just for using a F1 Table 👍🏼

Ответить
@romancarlosplasencia7108
@romancarlosplasencia7108 - 11.09.2023 22:33

Thanks for this video! Very helpful 💪

By the way, i've made a new JS Code for Table Aria Labels. Check it if you want!

function AddTablesAriaLabels() {
const tablesAriaLabels = document.querySelectorAll('table');
const captionsAriaLabels = document.querySelectorAll('caption');
const rowGroups = document.querySelectorAll('thead, tbody, tfoot');
const columns = document.querySelectorAll('th');
const rows = document.querySelectorAll('tr');
const cells = document.querySelectorAll('td');

if (tablesAriaLabels) {
tablesAriaLabels.forEach(tableAriaLabel => {
tableAriaLabel.setAttribute('scope','table');
});
}

if (captionsAriaLabels) {
captionsAriaLabels.forEach(captionAriaLabel => {
captionAriaLabel.setAttribute('scope','caption');
});
}

if (rowGroups) {
rowGroups.forEach(rowGroup => {
rowGroup.setAttribute('scope','rowgroup');
});
}

if (columns) {
columns.forEach(column => {
column.setAttribute('scope','col');
});
}

if (rows) {
rows.forEach(row => {
row.setAttribute('scope','row');

row.children[0].setAttribute('role','rowheader');
});
}

if (cells) {
cells.forEach(cell => {
cell.setAttribute('scope','cell');
});
}
}

Ответить
@sergei_sg
@sergei_sg - 15.09.2023 13:24

Thank you, Kevin! This is a great solution!

Ответить
@SergeiSerbulatov
@SergeiSerbulatov - 05.10.2023 21:27

Thank you for this valuable video! Kevin, it is the best solution for my project!

Ответить
@alexandruburcea6450
@alexandruburcea6450 - 08.10.2023 21:59

Many thanks

Ответить
@SmileThePlanet
@SmileThePlanet - 15.10.2023 23:02

this video is awesome (liked and subscribed :)
..but would you mind explaining, how to turn this into a mobile first design?

Ответить
@RenanLucenaDosSantos
@RenanLucenaDosSantos - 17.10.2023 17:29

TY!!!

Ответить
@StephaniLacerda
@StephaniLacerda - 20.10.2023 12:46

Loved Ayrton Senna inclusion 🤩😭

Ответить
@mrastrogastro
@mrastrogastro - 22.10.2023 10:22

Kevin what if we used grids for table layout? I think we could have much better control of everything. Position sticky will work + resize columns option.

Ответить
@gabrielferrin
@gabrielferrin - 01.11.2023 21:40

Great video! Thanks!

Ответить
@daimonien
@daimonien - 08.11.2023 22:09

Collapsing tables should be standard for every CMS since like decade ago...

Ответить
@24Ippo
@24Ippo - 21.11.2023 10:33

I've been struggling with CSS and every video you made has clarified every issue i have with. Now i can make decent web sites that doesn't look as they were made for Netscape

Ответить
@EdwardSmith-nq9wy
@EdwardSmith-nq9wy - 25.11.2023 08:15

This really helped me beef up my final, thank you!!

Ответить
@AlJey007
@AlJey007 - 27.11.2023 12:23

I also like to use the thead, tbody and tfoot. Gives a bit more flexibility for styling.

Ответить
@FaradayLabs
@FaradayLabs - 29.11.2023 10:26

Now, try to add vertical scroll into the body only, so header stays always visible. Would be nice to see how this could be achieved ;)

Ответить
@RoyerAdames
@RoyerAdames - 04.12.2023 03:39

I wish I had this technique for pass project

Ответить
@blocSonic
@blocSonic - 13.12.2023 23:32

Terrific ideas beyond the container overflow-x trick, which is what I have usually gone to. Thanks!

Ответить
@catalinim4227
@catalinim4227 - 15.12.2023 01:07

well, side scrolling on mobile works from any position... just sayin

Ответить
@Dylan_thebrand_slayer_Mulveiny
@Dylan_thebrand_slayer_Mulveiny - 01.01.2024 09:49

There is ZERO reason to be using tables in 2023. None whatsoever. Period. Tables are just plain awful and cause all sorts of problems. With grid and flex, they are 100% obsolete. If you're still using tables, you suck at your job.

Ответить
@keenoogodlike
@keenoogodlike - 08.01.2024 06:31

Life saver

Ответить
@ol1175
@ol1175 - 09.01.2024 04:36

Thanks a lot!

Ответить
@AbhishekKumar-ot9iv
@AbhishekKumar-ot9iv - 22.01.2024 10:32

This helps alot , Thanks @kevin

Ответить
@vincenzocristiano135
@vincenzocristiano135 - 26.01.2024 14:13

Kevin the man, the myth, the legend!

Ответить
@omarrosas5524
@omarrosas5524 - 03.02.2024 06:09

gracias.

Ответить
@다루루
@다루루 - 05.02.2024 14:20

매우 친근한 아저씨😊

Ответить
@magnoid
@magnoid - 19.03.2024 04:50

Kevin, this is Awesome. I'm so glad I found your channel! Loving pretty much every video you put out!

Ответить
@DanielKwan
@DanielKwan - 22.03.2024 07:31

This is awesome. Shopify unfortunately does not seem to support the "content" element. Does anyone know of a workaround? I'm not looking forwarding to adding headings to every single td and then hiding them for desktop view.

Ответить
@tomasvalent3876
@tomasvalent3876 - 24.03.2024 19:20

impressive 🤔💪

Ответить
@frontend_ko
@frontend_ko - 31.03.2024 14:36

wow... very practical tips

Ответить
@petrmotejlek1427
@petrmotejlek1427 - 08.04.2024 12:31

I'm missing tbody and thead :)

Ответить
@hasst9261
@hasst9261 - 14.05.2024 21:09

TY TY TY

Ответить
@jeromej.1992
@jeromej.1992 - 21.05.2024 01:40

Hello! What if the columns and rows are inverted? I can't find any solution to display one column underneath one another instead rows like u did in your example.

Ответить
@andygordon6880
@andygordon6880 - 24.05.2024 11:34

What a brilliant tutorial. Hits the mark perfectly and easy to follow. Thank you.

Ответить
@KirillBon
@KirillBon - 13.07.2024 00:45

Already 3 championship titles for Max :) so you need to update your video :)

Ответить
@tochimclaren
@tochimclaren - 21.07.2024 23:24

Table without thead and tbody... O boy.

Ответить
@justinkeeth
@justinkeeth - 07.08.2024 03:35

This video is exactly what I was looking for. Thank you!!

Ответить
@eric55099
@eric55099 - 21.09.2024 21:43

You taught me CSS and now I'm one of the best in the whole University..

Thank you Kevin

Ответить
@cerealez
@cerealez - 29.09.2024 21:19

I think we can re do it with the subgrid property.

Ответить
@Tsakos17
@Tsakos17 - 04.10.2024 16:07

This is a type of channel where you come thinking you know it all and by the time the video ends, you're 100 times wiser than before. Thank you very much Kevin!

Ответить
@AlThePal78
@AlThePal78 - 25.10.2024 18:36

You forgot the thead and tbody

Ответить
@AlThePal78
@AlThePal78 - 25.10.2024 18:50

it came in with a tbody but it did not keep your th elements, it changed them, it needed to bring in the thead and role = thead love this video. You have so many I have not seen but I am going to use this today. I have a table of data I was trying to figure out how to make it like this and this did it for me thanks :) maybe you didn't add thead and tbody because it might have changed out the information. Maybe I can find an alternative to data-cell or nthchilde() to add the th in front of the td when I make it responsive to mobile. But I liked both approaches but the nthchild I like more because you can change the name in one of them and don't need data-cell in every td element. Tables on a website don't usually have more then 5 columns anyways, well the ones I used ;)

Ответить
@shannonstumpf1861
@shannonstumpf1861 - 19.12.2024 04:37

what beautiful work. thank you!

Ответить