1

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
  • Like you said, the best two options aren't an option. This is the next best, is there any other alternative?
    – ediblecode
    Feb 24, 2015 at 17:22

1 Answer 1

1

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
  • +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."
    – mgw854
    Feb 24, 2015 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.