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

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.
主站蜘蛛池模板: 南宫市| 吉安市| 海宁市| 沂水县| 哈密市| 乌海市| 安康市| 崇义县| 沁阳市| 昌图县| 福贡县| 连南| 孝昌县| 锦州市| 鹤壁市| 临湘市| 青冈县| 永年县| 松桃| 崇文区| 柏乡县| 隆化县| 安义县| 泊头市| 锦屏县| 阳城县| 临海市| 乌兰县| 茶陵县| 边坝县| 辽宁省| 虹口区| 太谷县| 东乡族自治县| 连州市| 蕉岭县| 佳木斯市| 夏邑县| 呼玛县| 庄浪县| 东宁县|