- AMP:Building Accelerated Mobile Pages
- Ruadhan O'Donoghue
- 156字
- 2021-07-08 10:04:11
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.
- Spring Cloud Alibaba核心技術與實戰案例
- Practical UX Design
- 構建移動網站與APP:HTML 5移動開發入門與實戰(跨平臺移動開發叢書)
- Neo4j Essentials
- Mastering Kali Linux for Web Penetration Testing
- Building Cross-Platform Desktop Applications with Electron
- 移動界面(Web/App)Photoshop UI設計十全大補
- Java系統化項目開發教程
- Python自然語言理解:自然語言理解系統開發與應用實戰
- RocketMQ實戰與原理解析
- Java Web從入門到精通(第2版)
- Android技術內幕(系統卷)
- R語言實戰(第2版)
- 關系數據庫與SQL Server 2012(第3版)
- Mastering ArcGIS Server Development with JavaScript