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

Text layout with CSS and HTML

So we know how to customize the font. What about text layout? CSS can be applied to text in AMP, just like normal HTML. AMP also provides some additional text layout features.

Pull-quotes are quite common in news article content. It's a technique that's used to emphasize an important part of the text. One way to achieve this is by using a simple HTML blockquote tag (/ch3/pullquotes.html):

<blockquote class="pull-quote">
The whale is a mammiferous animal without hind feet
</blockquote>

Then we'll add a left border to the quote by adding the following CSS:

.pull-quote {
border:none;
border-left:6px solid #999;
font-size:1.5rem;
padding-left:1rem;
}

When viewed in a browser, you should see something like this:

Pull-quote using <blockquote> element (/ch3/pullquotes.html)

This is nice, but we can do better. Let's add a stylized quotation mark as a visual effect to really make the pull-quote stand out. We can achieve this with CSS, using the before pseudo-selector:

.pull-quote::before {
content: '\00201C';
font-size: 8rem;
font-family: Georgia, serif;
color: #ff8c00;
position: absolute;
left: -0.5rem;
line-height: 7rem;
padding-left: 1rem;
}

This CSS will output the value of the content property--in this case, it's \00201c, which is the unicode value for a double quotation symbol--before any element with class pull-quote. The remainder of the CSS just positions and styles the quote symbol.

The result is a nice, professional-looking pull-quote, as shown in the following image (/ch3/pullquotes.html):

Pull-quote with <blockquote> element and styling
主站蜘蛛池模板: 伊川县| 芦山县| 尼木县| 开江县| 乐亭县| 靖西县| 通山县| 通辽市| 桐乡市| 那坡县| 黄龙县| 五原县| 甘南县| 四川省| 容城县| 寿宁县| 乾安县| 株洲县| 西城区| 怀集县| 图片| 莆田市| 安仁县| 凤凰县| 竹溪县| 宜州市| 巴东县| 内江市| 丘北县| 比如县| 河池市| 城固县| 惠东县| 永和县| 河西区| 都江堰市| 霍州市| 皮山县| 石渠县| 防城港市| 桃源县|