首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS将段落缩进到插入的div?

问CSS将段落缩进到插入的div?
EN

Stack Overflow用户
提问于 2013-02-16 03:50:36
回答 2查看 414关注 0票数 0

我的目标是:除了.firstCharacter后面的段落之外,所有的段落都缩进。

我有一个引出我的页面中某些部分的第一段的首字下沉。我已经将第一个段落标记之后的所有段落标记都设置为使用...

代码语言:javascript
复制
.storyContainer p + p {
    text-indent: 1.5em;
    margin-top: 0
}

我正在设置我的首字下沉...

代码语言:javascript
复制
.firstcharacter {
    float: left;
    font-size: 80px;
    line-height: 60px;
    padding-top: 4px;
    padding-right: 8px;
    padding-left: 3px;
    font-family: 'Droid Serif', serif;
}

我的网址是这样的.

代码语言:javascript
复制
<div class="headline">This is a headline!</div>

<p><span class="firstcharacter">T</span>his text NOT indented because it's first</p>
<p>This text will be indented because it's second.</p>
<p>This text will be indented because it's third.</p>

<div class="someBox">This is some extra box</div>

<p>I want this to be indented but it won't be because it is first after the box!</p>
<p>This text will be indented because it's second.</p>

<div class="headline">This is a headline!</div>

<p><span class="firstcharacter">T</span>his text NOT indented because it's first</p>
<p>This text will be indented because it's second.</p>
<p>This text will be indented because it's third.</p>

<div class="someBox">This is some extra box</div>

<p>I want this to be indented but it won't be because it is first after the box!</p>
<p>This text will be indented because it's second.</p>

有没有什么能帮你把这个弄清楚的?

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2013-02-16 04:04:31

http://jsfiddle.net/WRKxQ/

html:

代码语言:javascript
复制
<div class="headline">This is a headline!</div>
<p class="firstcharacter"><span>T</span>his text NOT indented because it's first</p>
<p>This text will be indented because it's second.</p>
<p>This text will be indented because it's third.</p>
<div class="someBox">This is some extra box</div>
<p>I want this to be indented but it won't be because it is first after the box!</p>
<p>This text will be indented because it's first.</p>

<div class="headline">This is a headline!</div>

<p class="firstcharacter"><span>T</span>his text NOT indented because it's first</p>
<p>This text will be indented because it's second.</p>
<p>This text will be indented because it's third.</p>
<div class="someBox">This is some extra box</div>
<p>I want this to be indented but it won't be because it is first after the box!</p>
<p>This text will be indented because it's first.</p>

css:

代码语言:javascript
复制
p {
    text-indent: 1.5em;
    margin-top: 0
}

.firstcharacter {
    text-indent: 0;
}

.firstcharacter span {
    float: left;
    font-size: 80px;
    line-height: 60px;
    padding-top: 4px;
    padding-right: 8px;
    padding-left: 3px;
    font-family:'Droid Serif', serif;
}

这应该能解决它吗?

我基本上只是稍微改变了一下你的css和html。

玩得开心

jascha

票数 0
EN

Stack Overflow用户

发布于 2013-02-16 04:12:45

对于第一行,您可以使用p::first-line{}来缩进它。对于第一个字符,可以使用p::first-letter.For IE<9,您只需使用一个冒号。

要选择第一个段落之后的所有段落,可以使用第n个子代(N)伪类。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14902270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档