Problems changing image height with CSS

  • Profile Image
    betwrestling
    Asked on March 23, 2017 at 04:18 PM

    I am trying to change the height of an image with CSS code however for some reason it doesn't seem to be working. I can change the width fine, but not the height. Is this the correct code?       

     

    img.form-image {

            width : 68%;

              height: 10%;

        }

  • Profile Image
    Kiran
    Answered on March 23, 2017 at 07:01 PM

    Could you try having the height as auto to see if that helps?

    img.form-image {

            width : 68%;

            height: auto;

    }

    Please get back to us if the issue still persists. We will be happy to help. 

  • Profile Image
    Predictwrestling 
    Answered on March 23, 2017 at 11:07 PM

    Thanks for that however I only want the width and height to change when viewing it on mobile devices, so having it automatic wouldn't work.

  • Profile Image
    BJoanna
    Answered on March 24, 2017 at 04:11 AM

    If you want to change the size of you image only on mobile devices you will have to use @media query

    If you want to find out more about media query CSS codes targeting different devices, here’s one good source. http://stephen.io/mediaqueries/

    For example you can use try with this CSS code:

    @media screen and (min-width: 10px) and (max-width: 540px){

    img.form-image {

              width : 68%;

              height: 10%;

        }

    }

    Hope this will help. Let us know if you need further assistance.