官术网_书友最值得收藏!

Using the heights and sizes attributes

The heights and sizes attributes allow us to further tweak the display of our responsive images. The sizes attribute lets us use a media query to define how wide an image should be displayed, depending on the size of the user's viewport. Take the following code, for example:

sizes="(min-width: 640px) 50vw, 100vw"

This means that for screen sizes of 640 pixels and wider (min-width: 640px), the image should take up 50 percent of the viewport width (50vw). For all other screen sizes--that is--those less than 640 pixels, display the image at 100 percent of the viewport width: (100vw).

The heights attribute achieves a similar effect, but unlike sizes, it applies to the height of the image instead of the width, for example:

heights="(min-width:500px) 200px, 80%"
When the heights or sizes attribute is specified along with width and height, the layout defaults to responsive.
主站蜘蛛池模板: 宁乡县| 横峰县| 滁州市| 张北县| 韶关市| 休宁县| 墨竹工卡县| 会理县| 新竹市| 永昌县| 吉林市| 高州市| 夹江县| 宣化县| 稻城县| 苗栗县| 清原| 文化| 满城县| 彭水| 金昌市| 青川县| 南充市| 长泰县| 县级市| 吉首市| 吉首市| 恭城| 呈贡县| 泌阳县| 如东县| 伊通| 黔江区| 上栗县| 兴隆县| 肥东县| 桐城市| 太仆寺旗| 三河市| 阜阳市| 洪泽县|