【问题标题】:How can I make the first letter push itself into the paragraph like a newspaper style我怎样才能让第一个字母像报纸风格一样推入段落
【发布时间】:2016-04-06 09:42:49
【问题描述】:

我创建了一些 CSS 来处理段落中的第一个字母看起来更大,

如何使第一个字母向下和向左推,使其不会高于行本身,并在需要时将其他行向右缩进? (见附图)

.text-article {
    color: #000;
}
.text-article:first-letter {
    font-weight: bold;
    font-size: 60px;
    font-size: 6rem;
    line-height: 10px;
    line-height: 1rem;
    text-transform: uppercase;
}
<div class="text-article">
We the People is a section of the whitehouse.gov website, launched September 22, 2011,[1] for petitioning the current administration's policy experts. Petitions that meet a certain threshold of signatures are most of the time reviewed by officials in the Administration and official responses are then issued, but not always, as outlined in the Criticism section.[1] Criminal justice proceedings in the United States are not subject to White House website petitions. In fact, no real processes of the federal government are subject to these White House website petitions; they are a public relations device for the present administration which permits citizens to express themselves. On August 23, 2012, the White House Director of Digital Strategy Macon Phillips released the source code for the platform.[2] The source code is available on GitHub, and lists both public domain status as a work of the U.S. federal government and licensing under the GPL v2.[3]
</div>

【问题讨论】:

  • 你需要什么?所有行的第一个字母都大?
  • 这些被称为“首字下沉”。
  • Drop-caps using CSS的可能重复
  • 谢谢 torazaburo - 很高兴知道。

标签: html css


【解决方案1】:

您可以使用float:left 让第一个字母向下移动并将其他行推开。您还需要调整line-height 使其更大一些——我使用了40px/4rem

.text-article {
    color: #000;
}
.text-article:first-letter {
    float:left;
    font-weight: bold;
    font-size: 60px;
    font-size: 6rem;
    line-height: 40px;
    line-height: 4rem;
    height:4rem;
    text-transform: uppercase;
}
<div class="text-article">
We the People is a section of the whitehouse.gov website, launched September 22, 2011,[1] for petitioning the current administration's policy experts. Petitions that meet a certain threshold of signatures are most of the time reviewed by officials in the Administration and official responses are then issued, but not always, as outlined in the Criticism section.[1] Criminal justice proceedings in the United States are not subject to White House website petitions. In fact, no real processes of the federal government are subject to these White House website petitions; they are a public relations device for the present administration which permits citizens to express themselves. On August 23, 2012, the White House Director of Digital Strategy Macon Phillips released the source code for the platform.[2] The source code is available on GitHub, and lists both public domain status as a work of the U.S. federal government and licensing under the GPL v2.[3]
</div>

【讨论】:

  • 谢谢卡特,我有时有点 CSS 迟钝 :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-09
  • 2018-02-02
  • 2014-01-02
  • 1970-01-01
  • 1970-01-01
  • 2022-09-28
相关资源
最近更新 更多