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

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
主站蜘蛛池模板: 洪湖市| 拉萨市| 九江县| 长丰县| 儋州市| 兴和县| 安远县| 河池市| 长丰县| 康定县| 额敏县| 西平县| 北碚区| 黎川县| 内乡县| 常德市| 汾西县| 盘山县| 邵武市| 溧水县| 新丰县| 班戈县| 张家港市| 濉溪县| 闸北区| 四平市| 左云县| 大关县| 年辖:市辖区| 孟连| 阿图什市| 曲周县| 长宁区| 隆德县| 南投市| 临颍县| 永和县| 电白县| 彰化市| 宁明县| 吉隆县|