I was asked to take over a web project. It is supposed to be a responsive website, but the former programmer didn't write the HTML/CSS with responsivity in mind and adding code to make it responsive would be a nightmare. Mobile version on m.domain.ltd is not acceptable by the client for some reason. Is it OK to just replace whole page (ajax call to server) with another content when the window is resized or loaded in, say, <780px? Thanks
1 Answer
Replace the whole content with an ajax call? Nevar! That is an insane idea!
CSS3 now supports what's called "media queries" which figures out the width and height of your viewport and can set new CSS rules.
Here's a sample from one of my current projects
@media only screen and (max-width: 1260px) {
#left_wrap {
visibility: hidden;
}
#usercard {
background: magenta;
}
#right_wrap {
margin-left: 10px;
width: 926px;
}
#shortWidthUserCard {
visibility: visible;
}
}
Earlier rules set different values, when the width is less than 1260px for the viewport, these rules above are applied.
Be nice to the guy who's going to maintain the code after you.
-
+1 for thinking about the next person. "Code as if the next guy to maintain your code is a homicidal maniac who knows where you live."– mgw854Feb 24, 2015 at 20:58