r/HTML • u/Eulevonathen • Oct 11 '26
Question Difference in screen size
Hello. I've created a website using HTML, CSS, and JavaScript for the first time. My problem is this: I wrote the code on a computer and adjusted the sizes to fit the large screen. Now, on my laptop, which has a smaller screen, everything is misaligned. Can you tell me how to fix this problem?
Thank you very much
3
Upvotes
16
u/atarivcs Oct 11 '26
https://en.wikipedia.org/wiki/Responsive_web_design
11
u/rackodo Oct 11 '26
Since everyone else in the replies are acting like children:
Look into responsive CSS! You can use media queries to set different rules based on the max width of the user's screen. Use this as a starting guide, and experiment from there.
1
u/aunderroad Oct 11 '26
Can you share a url or codepen?
It is hard to debug/provide feedback without seeing all of your code live in a browser.
Thank you!
2
u/gastapo67 Oct 11 '26
If you open the website in DevTools on Chrome on the computer you wrote the website on, you can adjust the screen size to any layout to see how the website will look at that resolution. Then it’s applying the responsive web design to accommodate the adjusted resolutions
1
u/Reasonable-Pay-8771 Oct 16 '26
One approach to consider *before* resorting to media queries and laying out multiple formats is: remove all your hardcoded sizes and: use fractions of the screen size for big things and use normalized units or relative increases/decreases for small sizes and: use as much semantic html as you can instead of divs which carry no intrinsic meaning.
Does that make sense? If you don't start by building it to a particular size but arrange everything in a proper hierarchy (maybe with flexboxes and such) then it will be more responsive without hardcoding even more particular sizes for different phone dimensions etc.
1
u/notepad987 Oct 12 '26
Examples at link:
Responsive Web Design Using Media Queries
https://www.geeksforgeeks.org/html/responsive-web-design-using-media-queries/
Layout Flexbox test - link to a GRID version too:
https://codepen.io/davidhelp/pen/ByQyPWr?editors=1100
1
u/olets Oct 14 '26
https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Responsive_Design
-2
u/RealNamek Oct 12 '26
if largeScreenSize: showLargeSite()
if smallScreenSize: showSmallSite()
-6
u/Friendly_Antelope807 Oct 11 '26
Google shit
-9
u/Friendly_Antelope807 Oct 11 '26
ASK Ai