Preface
there are like. a billion ways to do this so i wont get into every thing you can do to approach responsiveness. the purpose of this is to present different methods and for you to choose whichever, or come up with your own way using this a sort of ~springboard~
keep in mind complete screensize responsiveness isnt just making a page look the same on all devices. it involves much planning and structuring your content as a whole to be mobile accessible. different methods also fit different types of pages! a gallery will need to fit different accomodations from a blog, etc etc. in this same vein, not every piece of information here will cover all the things a certain type of page needs to be responsive.
my biggest reccomendation is to look at your site on other devices (i.e. phone, tablet, etc.) to see how your layout is affected
p.s. ill move this disclaimer to the main page when i make it but this is all my advice and what ive learned. if i got anything wrong (which i probaby have kek) or you have additions let me know to improve the resource!Not responsive
html width
by adding width:[your screen width in px (i.e. 1080px)]
to your body
, you can make your page look the exact same* on all devices!
this method makes it so every device with a screen width smaller than the width you set not affect elements that would otherwise be resized...below is a demo of what i mean
by using this technique, your page will behave like box b.
assuming you have some items that are affected by screen width, this simple fix will totally stop all the resizing and stuff from happening on devices with a screensize ≤ the set width.
this is good if you have a very detailed page, but keep in mind this doesnt make your page neccesarily pleasant to navigate/view. many of my older pages use this and when on mobile, youd have to scroll all over the place to read and navigate a page....its not ideal for accessibility. screensizes bigger than the width you set & it may not fully work depending on how you code your site* but it works!
* - note: if you have elements with thepositon: absolute
(most of the time) and positon: fixed
property, results with this method will (probably) be reallyyy shit.
the accompanying properties
top
, left
, right
and bottom
use the screen size as reference (most of the time) and will show in ways not desired, sometimes obstructing content. theres ways to get around this but its better if you limit the usage of these properties not just for this but in general (advice from someone clinically addicted to both of these)
Semi-Responsive
margin: auto
margin: auto
Responsive
html width
@media
this one will probably take the longest to impliment but if you want your site to be very accessible to mobile and all, this is what you want to do!
im not gonna explain what @media
is because its only kind of important, but heres the w3school page and mozilla dev reference, read if you so please. basically it detects attributes of a device. most importantly, in our case, screen size.
inside the selector @media and screen (max-width:[size])
, we can put other rules inside of it, like this
@media
rule, but add !important
after all the previous
all the rules inside of it will only apply when the size of the screen is the set size. this allows for many possibilities and is the best way (i know of) to format your site to be mobile friendly.
a live example ill show is my dreams page. if youre on desktop, try resizing the screen. youll notice the left column dissapears, the header is reformatted, etc.
this goes very nicely with flexbox (which if you havent learned u should)
soo, yes, what i think is best to achieve screensize compatibility is to reformat your entire website to be easier to navigate this way. this can be easy or hard depending on the complexity of your website and how its coded already.
- again, if you arent already using flexbox and you have any kind of multi columned or stacking layout, switch to that for an easier life
- for uneccesary details that obstruct content on mobile/are purely decorational but make the mobile viewing inconvinent in any way, my fix is as follows:
- as mentioned in the intro, complete mobile friendliness is directly affected by the layout of your site itself. it cannot be achieved with just css, but html structured in a naturally adaptable and intuitive way. make sure your layout is following a clear, linear hierarchy