什么是固有的,为什么图像未加载正确的尺寸?

时间:2019-09-30 10:46:42

标签: css responsive-design

我正在尝试加载图像,但是当我使用chrome开发工具查看时,它显示为300×156像素(本征值:600×312像素)。为什么我的班级设置为mysql-connector-cC:\Qt\Qt5.12.5\5.12.5\mingw73_64\bin

width:auto

1 个答案:

答案 0 :(得分:-2)

首先,您在img标签上使用的类是hero__main,而您提供的css是用于myImg的,因此应该相同...

<img src="myImg.png" class="myImg" />

.myImg{
    width: auto;
    height: auto;
    margin-bottom: 30px;
}

现在...您的img小于图像的原始分辨率。可能是因为我刚刚指出了该类错误。或者您在某处设置了max-width:100%;用于图像。所以试试这个:

.myImg{
    width: auto;
    height: auto;
    margin-bottom: 30px;
    max-width:none;
    max-height:none;
}