I'm new to CSS and to this forum. But I've been working on a little project where I want the image in my site to completely change when the browser is resized.
I've been using media-queries? but I can't seem to get it right. any thoughts/tips?
I'm new to CSS and to this forum. But I've been working on a little project where I want the image in my site to completely change when the browser is resized.
I've been using media-queries? but I can't seem to get it right. any thoughts/tips?
You can use the
content
property to insert your image. However, images included like this could be difficult to style. (Run code snippet in full screen before resizing browser)This can be done using the HTML5
picture
element which doesn't require CSS for changingimg
elements on specified media queries. If you're intrested in this approach, do be aware of its browser support which does NOT include IE, though there is a polyfill for older browsers.In the future please add code you've tried.
if it's an
image
tag you can use a class. Hide the second image on page load and show + hide image 1 at a certain screen size like so:HTML
CSS
EXAMPLE 1 - SHRINK BROWSER
OR
If it's a
background-image
you can simply swap the image:HTML
CSS
EXAMPLE 2 - SHRINK BROWSER