Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6969591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:36:02+00:00 2026-05-27T16:36:02+00:00

Just a question about css for mobile devices, i have an image that is

  • 0

Just a question about css for mobile devices,

i have an image that is 1260px wide on my website and when i look at it on the phone it destorts the website as the rest of the website is based on a 960px layout.

I have made these images to be now 960px wide for the mobile device but how do i specify in css that if it is a mobile use mobile optimized image instead of the one on the regular website.

So basically if a user goes on the website on a desktop computer it will show the 1260px image

and if they visit the website on a mobile it will display the 960px image

any ideas guys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:36:03+00:00Added an answer on May 27, 2026 at 4:36 pm

    Im not sure if you want JS, i decided to answer your question if you want CSS3, try this:

    HTML:

    <img src="image.jpg"
         data-src-960px="image-960px.jpg"
         data-src-1260px="image-1260px.jpg"
         alt="">
    

    CSS:

     @media (min-device-width:320px) {
            img[data-src-960px] {
                content: attr(data-src-960px, url);
            }
        }
    
        @media (min-device-width:960px) {
            img[data-src-1260px] {
                content: attr(data-src-1260px, url);
            }
        }
    

    jQuery version:

     $(document).ready(function() {
    
     function imageresize() {
     var contentwidth = $('#content').width();
     if ((contentwidth) < '960'){
     $('.imageclass').attr('src','image-960px.jpg');
     } else {
     $('.imageclass').attr('src','image-1260px.jpg');
     }
     }
    
     imageresize();//Activates when document first loads    
    
     $(window).bind("resize", function(){
     imageresize();
     });
    
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick question about best practice in MVC development. Let's say that I've
I just downloaded a website template that is in a .PSD form. I have
I have a really, really simple CSS question that has already been asked here
Had a question that I've often wondered about. Is it better to have multiple
I was just wondering about CSS for IE. Typically we have a separate style
I have about 10 referenced CSS and JavaScript (JS) files on my website and
Just got a question about generics, why doesn't this compile when using a generic
Just a general question about what the best practice is: public void Foo() {
Just a quick question about ReadWriteLocks in Java (specifically the ReentrantReadWriteLock implementation) as I
Just a quick question about how parameters are passed in Java... ... if ((index

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.