this post was submitted on 05 Aug 2023
1 points (60.0% liked)
Web Development
3439 readers
11 users here now
Welcome to the web development community! This is a place to post, discuss, get help about, etc. anything related to web development
What is web development?
Web development is the process of creating websites or web applications
Rules/Guidelines
- Follow the programming.dev site rules
- Keep content related to web development
- If what you're posting relates to one of the related communities, crosspost it into there to help them grow
- If youre posting an article older than two years put the year it was made in brackets after the title
Related Communities
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
Wormhole
Some webdev blogs
Not sure what to post in here? Want some web development related things to read?
Heres a couple blogs that have web development related content
- https://frontendfoc.us/ - [RSS]
- https://wesbos.com/blog
- https://davidwalsh.name/ - [RSS]
- https://www.nngroup.com/articles/
- https://sia.codes/posts/ - [RSS]
- https://www.smashingmagazine.com/ - [RSS]
- https://www.bennadel.com/ - [RSS]
- https://web.dev/ - [RSS]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I also tried that but it just renders a single row. Probably because I'm missing something...
Did you read the article? You need to define the number of rows.
If that's the case, I think that doesn't really help. The original issue is that I need to edit the CSS file every time a new chapter is added. Which would be the same if I have to hardcode the number of rows.
I mean, it's a bit cleaner to hardcode the number of rows than the height in pixels, but I was looking for a solution that doesn't require magic numbers in the CSS.
Thanks!
Well you can do a little math to figure it out yourself in that case.
--row-count: item-count / column-count
(you need to substitute the item and colum count yourself) You can do something like that in an inline style to define the number of rows. Then in your css define do thisgrid-template-columns: repeat(var(--row-count), 1fr);
this will make it so that the row count is defined in the html which can be dynamic without having to change the css.(If the ideal solution is not possible) I think you are right.
Let me check I understood: the idea is to have a single changing-magic-number (the number of menu options) set in a variable
--item-count
and then calculate all the other values from that. The--column-count
would be fixed for each resolution step, so that's ok.Thank you very much for the help!
Yeah more or less. I'm not sure what's rendering your html though, myself I'd do the math in js and just set the row-count variable off the value in the inline style, but it depends on what's doing your dynamic rendering.
Yep, a bit of JS is another option.
Nothting really, I wanted to keep the project very simple (because there are non-devs contributing to it) and the HTML is static code.