Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Queries vs JS Media Queries for changing layout #62

Open
VaseJS opened this issue Jan 17, 2024 · 0 comments
Open

Media Queries vs JS Media Queries for changing layout #62

VaseJS opened this issue Jan 17, 2024 · 0 comments

Comments

@VaseJS
Copy link

VaseJS commented Jan 17, 2024

I've read your AMA to look for this question and found it but you have the same answer as you did in during a Q&A in another video/talk of yours. The one from the AMA was:

"How do you normally make ITCSS 'components' responsive? I've seen the use of responsive classes, but do you ever use media queries within your component's CSS?"

Your response was:

"If a specific component needs to have a different appearance over several breakpoints, I write MQs inside of it. Responsive classes are usually reserved for utilities where responsive behaviour can be abstracted."

However this doesn't address going from wide to narrow screen where the items may go from multiple columns to one.

I use the ITCSS meta framework but in all your videos or articles, I haven't found any examples in all my notes. It seems like changing o-col-10 (spanning 10 of the 24 columns of the grid) would not work with media queries changing o-col-10 to span more than 10 columns.

Is the problem my level of specificity? Should I have the column more generic like o-col-narraw, o-col-med and o-col-wide?

The other solution is to use JS to detect screen size and swap out the classes appropriately, e.g.:

function foo() {
if (window.innerWidth < 1024) {
/* change needed classes */
}
}
// Set up a listener
window.addEventListener('changesize', foo);

@VaseJS VaseJS changed the title Media Queries vs JS Media Queries for chaning layout Media Queries vs JS Media Queries for changing layout Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant