Search code examples
javascriptcssmedia-queries

Different image size for pc and mobile using css or js


there is different size images in my website. and i want to set 2 different image width for some images, first for big screens like PC and second for small screens like mobile etc. for small screens width at 80% and for big screens width at 300px.


Solution

  • well its simple place this in css .image { width: 300px; height: auto; } @media (max-width: 500px) { .image { width: 80%; height: auto; } }

    and add img class="image"