Detect screen size

Posted on 2014-07-19
Last Modified: 2014-07-20
I'm working on a  "full screen, background image based" website that looks pretty bad on mobile since the pictures don't shrink as small as I need them to on mobile.

I'm basically looking for a javascript that can detect if the screen is smaller than ex: 800x500 and provide a certain div with a different class than the one assigned too it.

That way a different class will load depending on the users screen size.

Question by:zahimezher
    LVL 52

    Accepted Solution

    The term  you are looking for is media query

    @media (max-width: 800px) { {
        background-image: url(yourimage);

    Open in new window

    LVL 1

    Author Closing Comment

    Amazing Thanks ;)

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
    Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
    In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
    In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now