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

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.
主站蜘蛛池模板: 聊城市| 东源县| 盖州市| 龙江县| 焦作市| 天等县| 德安县| 阿拉善右旗| 云阳县| 石门县| 寿宁县| 商都县| 双柏县| 灵石县| 乐陵市| 阿图什市| 东莞市| 哈密市| 高州市| 丰县| 金秀| 江阴市| 崇信县| 龙岩市| 玛曲县| 海盐县| 凤冈县| 抚宁县| 彭阳县| 英吉沙县| 宁河县| 富锦市| 雷州市| 民县| 团风县| 沾益县| 金湖县| 桐乡市| 阿拉善右旗| 安吉县| 榆社县|