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

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
主站蜘蛛池模板: 军事| 兰西县| 分宜县| 安徽省| 宜城市| 河源市| 双流县| 玉林市| 京山县| 霍林郭勒市| 高阳县| 岳阳市| 呼玛县| 上杭县| 华池县| 大英县| 新昌县| 正安县| 莱阳市| 两当县| 西藏| 临沭县| 涪陵区| 青河县| 达拉特旗| 镇雄县| 健康| 都昌县| 邯郸市| 崇义县| 广州市| 甘孜县| 同心县| 峨眉山市| 丰宁| 卢湾区| 嘉善县| 宜兰市| 阿合奇县| 塔城市| 元阳县|