How can I change the css so it fits on mobile? I can't figure out how to make the width smaller, you always need to scroll. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can I change the css so it fits on mobile? I can't figure out how to make the width smaller, you always need to scroll.

https://code.sololearn.com/WCti9u8xV7VW/?ref=app

25th Apr 2023, 4:11 PM
Hofmann
Hofmann - avatar
7 Answers
+ 6
To make the width responsive, adjust the elements’ width to 100% or 100vw. Read Yasin Rahnaward and Justice comments. They are more experinced in web than me.
25th Apr 2023, 4:50 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 5
Hofmann Never and never set a div or any other container element to a static width 100%, rem,px ... it causes overflow instead use min-width or max-width for your div. add these code to your #flex div Display:flex; flex-wrap:wrap and removed all your statics value for width
25th Apr 2023, 4:59 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 4
Justice Hofmann There are three ways to making layouts responsive 1. Media query 2. Flexing elements 3. Using grid It's up to developer how he/she can handle her/his layouts, people usually use media query with flexing or media query with grid which needs alots of time and patient to make the demands output. But I shared my little experience there is nothing else you cloud use what ever you know and get the result. [Example]: you have a dive with nth number of elements inside, easily what css can do to mak it response to all devices is just with 6 line code. Container{ display:flex; gap:10px; flex-wrap:wrap; } ForInnerItemClass{ display:grid; gap:1rem; grid-template-column:repeat(auto-fill,minmax(min(100%,250px),1fr)) }
25th Apr 2023, 5:49 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 3
In addition to what Ugulberto Sánchez , you can use Bootstrap containers that usually do the scaling for you and/or also use Media Queries via CSS. Here's a page on Media Queries and just as a tip, I like making the background-colors of each query different so I can tell the size of the device I am affecting: https://www.w3schools.com/css/css3_mediaqueries.asp
25th Apr 2023, 4:59 PM
Justice
Justice - avatar
+ 3
Justice for most of case there is no need to media query as they would be helpful but you have to check, handle and add media query to each device size . https://code.sololearn.com/WF72kzZhngEw/?ref=app
25th Apr 2023, 5:09 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 2
Yasin Rahnaward You stated yourself they would be helpful, haha, so I don't see the harm in letting someone know that is an option. :)
25th Apr 2023, 5:16 PM
Justice
Justice - avatar
+ 1
I apllied all the awesome help I got and fixed the issues. HUGE thanks for the help, I learned a lot! :)) https://code.sololearn.com/WCti9u8xV7VW/?ref=app
25th Apr 2023, 7:33 PM
Hofmann
Hofmann - avatar