图片在移动设备中拉伸 css

Img stretched in mobile css

我正在尝试建立一个简历网站。从手机 phone 上看时,我的图像有问题。看起来很拉长。

我用的CSS在这里:

        .image-featured img
    {
        position:absolute;
        top: 0;
        bottom:0;
        height: 100%;
        margin-left:auto;
        margin-right:auto;
        border-radius: 0.35em;      
    }

图像看起来被拉伸了。我不介意不显示左右两边的一些厘米。如果我尝试 height: relative; 它看起来不错,但离下一个街区很远。

height: 100%; 总是拉伸到屏幕高度,不影响宽度。更好的方法是使用 Jquery 设置相对于宽度的高度。一种方法是找到 height:width 的比率(例如 1px:1.75px)并将其应用于宽度

$(window).ready(function () {
   var height = screen.height;
   var width = height * 1.75 + 'px';
   $(img).css('height',height);
   $(img).css('width',width);
};