【问题标题】:Set image's height equal to dynamic width (using CSS only)设置图像的高度等于动态宽度(仅使用 CSS)
【发布时间】:2014-04-23 16:03:42
【问题描述】:

是否可以设置与宽度相同的高度?

css

img{
    width:90%;
    height: same as width;
}

由于屏幕宽度和高度不一样,所以如果宽度是 90%,高度应该是相同的像素高度

【问题讨论】:

标签: css image height width equals


【解决方案1】:

以像素为单位使用宽度和高度

img {
    max-width: 100%;
    height: auto;
    width: auto\9; /* ie8 */
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    • 2020-06-11
    • 2015-02-07
    • 1970-01-01
    • 2014-11-11
    • 1970-01-01
    • 2016-03-08
    相关资源
    最近更新 更多