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

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
主站蜘蛛池模板: 汝州市| 宁河县| 刚察县| 弥勒县| 本溪市| 博乐市| 岳阳县| 车致| 郑州市| 沾益县| 苏尼特右旗| 正宁县| 定兴县| 乾安县| 盐城市| 宝应县| 葫芦岛市| 汝南县| 方城县| 浏阳市| 大方县| 竹溪县| 霍邱县| 青冈县| 南投市| 库尔勒市| 聂荣县| 胶州市| 桐乡市| 铁岭市| 荔浦县| 通州市| 东乡| 贺州市| 林甸县| 剑川县| 开封市| 和静县| 临沭县| 高邑县| 贵定县|