使用element +元素定位多个以下元素 [英] targeting more than one following element with element+element

查看:132
本文介绍了使用element +元素定位多个以下元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的是使用以下代码定位多个< p>

What I want to do is target more than one <p> with the following code:

h1+p
{
    margin-left: 20px;
}

h2+p
{
    margin-left: 27px;
}

h3+p
{
    margin-left: 35px;
}

以下是我想达到的效果:

Below is the effect I am trying to achieve:

问题是,当有一个新的< p> 元素时,文本块显然会恢复到正常位置,没有边距,

The problem is that when there is a new <p> element, the block of text is obviously going to revert to it's normal position, without the margin, and not longer inline with the heading.

(像这样)

有更好的方法来解决这个问题吗? (或其中一个工作的)

Is there a better way of attacking this problem? (or one that works for that matter)

推荐答案

这是你想实现? http://jsfiddle.net/chrismackie/5DgNH/

这篇关于使用element +元素定位多个以下元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆