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

Text layout with <amp-fit-text>

We could also achieve this with AMP's amp-fit-text component. This component allows us to specify a fixed width and height, and minimum and maximum font sizes, and amp-fit-text will scale the font to fit the text within these constraints. Let's change our pull-quote example to use amp-fit-text instead of blockquote.

Since amp-fit-text is an extended component, it must be explicitly loaded in the head of the page like this:

<script async custom-element="amp-fit-text" src="https://cdn.ampproject.org/v0/amp-fit-text-0.1.js"></script>

Next, add this code somewhere within the main content in the body of the page:

<amp-fit-text width="400" 
height="75"
layout="responsive"
min-font-size="24"
max-font-size="48">
The whale is a mammiferous animal without hind feet
</amp-fit-text>

The min-font-size and max-font-size attributes ensure that the pull-quote will be neither too small on small screens, nor too large on large screens.

This sort of works, but we've lost some of the nice styling. Once again, we can spruce it up visually with a stylized quotation mark. This time, let's take this opportunity to demonstrate SVG support in AMP.

主站蜘蛛池模板: 陇西县| 从江县| 宁明县| 芜湖县| 岐山县| 外汇| 霍林郭勒市| 新田县| 屏山县| 晴隆县| 临夏市| 定边县| 湟中县| 科技| 昭苏县| 安多县| 青神县| 九寨沟县| 扬中市| 枣强县| 葫芦岛市| 土默特左旗| 宜昌市| 原平市| 禹州市| 和龙市| 景泰县| 上饶县| 台中县| 柘城县| 阳原县| 清原| 虞城县| 习水县| 宜兰市| 建湖县| 武汉市| 勐海县| 南和县| 青阳县| 东乡族自治县|