How to size an image to be 100% width of the screen, but only if


I would like to put an image on a website. I would like it not to be a background image, but a normal image, what I can later use for hovers and <em>"hover over some region, something changes on the screen"</em> kind of interactions.

What I would like to do is to make this image 100% width of the browsing area, but only if the screen is smaller than 1024px. If the screen is bigger, then I want the image to be exactly 1024px wide.

How would you do this? Somewhere I've read that CSS3 can do automatic background-width to fit with the browser window, but I think by using background image I cannot do interactive trick on the image later. But I've never done interactive tricks, so maybe it's possible.

<em>By interactive tricks I mean that if the mouse pointer is over a polygon region, then a div or an image changes or appears somewhere. Can you point me where to read about this technique, and how is it called?</em>

I have no experience in JavaScript, I've only used premade JS plugins, but if you say that for this problem I really should use JS then I have no problem with that.


use css max-width <a href="https://developer.mozilla.org/en/CSS/max-width" rel="nofollow">https://developer.mozilla.org/en/CSS/max-width</a>


<img src="flower.jpg" class="no-bigger-than-1024"/>


.no-bigger-than-1024{width:100%; max-width:1024px;}


img { max-width:1024px; width:100%; }


  • How can I gracefully degrade CSS viewport units?
  • CSS/XHTML Menu - Working in all browsers - IE6 Help
  • Password-protect the macros of a second workbook from a first using VBA
  • CSS border-image - critical
  • Webpage with wide iframe is not scrollable on an iPhone with viewport
  • fonts in tables rendering inconsistently on mobile browsers
  • ruby - lazily iterate through an array
  • How to enforce project-wide unique ids/error codes for easily finding the origin of the error in sou
  • Is there any way to center certain columns in table?
  • Adaptive Triggers in Resource Dictionary
  • Is Android development possible on netbooks? [closed]
  • How to resize image if the image is bigger than Textbox.But it not increase scale if smaller
  • Get or convert Week of year to ISO week
  • Selection Sort, For Java
  • Is it possible to specialize on a static lifetime?
  • Is it possible to “shrink” a PdfPtable?
  • Prevent parent page from scrolling when mouse is over embedded iframe
  • How can I determine which routines MATLAB uses to solve a sparse matrix?
  • Meteor.. accounts- password— Create account on client without login
  • Adding directive inside the directive programatically
  • Quick Question About Get and Set
  • How do you remove the JComboBox 'click and see dropdown' functionality?
  • (Play 2.5) How do you define json format for type alias of an Option?
  • Is it safe to drop the -webkit vendor prefix from the css3 border-radius yet?
  • Efficient & Pythonic way of finding all possible sublists of a list in given range and the minim
  • react split panel resize
  • redirect_to root_url and return unless @user.activated
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Android device acting as an accessory
  • uniform generation of points on 3D box
  • Custom validator control occupying space even though display set to dynamic
  • Change multiple background-images with jQuery
  • Ajax Loaded meta Tags
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Change an a tag attribute in JavaScript based on screen width
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • Django query for large number of relationships