问题描述
我有一个网站有一些文本功能,但它的确意味着许多嵌套 blockquote
s是一种可能性。现在我想知道是否可能使嵌套块引用的样式不同于另一个!
I have a site with some text features, but it does mean that a multitude of nested blockquote
s is a possibility. Now I am wondering if it is possible to have the styling for nested blockquotes be different from eachother!
blockquote{
background-color:#666;
color:#fff;
border:1px #000 solid;
}
这是一个blockquote样式的简单版本。我的问题是这样的:
so that is a simple version of a blockquote styling. My question would be this:
我可以做什么,使得blockquote中的每个其他blockquote都有一个黑色的背景!
What can I do to make it such that every other blockquote within a blockquote has a black background instead!
这样的!也许只有第4个嵌套的块引用有一个白色边框。
Anything like that! Maybe only the 4th nested blockquote has a white border.
只要能够操作嵌套的块引用,我就会非常有用!
Just being able to manipulate nested blockquotes would be very useful to me!
谢谢!
PS
编辑注意:
我实际上不能给 blockquote
赋予id,因为它基于用户。如果你使用ID或类,它必须通过jquery添加到特定的块引用中。
I cannot actually give ids to the blockquote
s because it is based through users. If you do use IDs or Classes, it must be added to the specific blockquotes through jquery
推荐答案
css class to every even blockquote
:
This uses jquery to apply a specific css class to every even blockquote
:
$('blockquote').each(function(index, element){
if(index % 2 == 0) { $(element).addClass('even'); }
});
你可以扩展这个来定制一个特定的元素(我们说第四个块引用) code> index == 3
You can extend upon this to customize a specific element (let's say the 4th blockquote) by checking for index == 3
这样可以节省编写和维护额外CSS的麻烦,你的html元素。这里有一个JS小提示来说明:
This should save you the hassle of writing and maintaining extra CSS or setting static, arbitrary IDs on your html elements. Here's a JS fiddle to illustrate: http://jsfiddle.net/ncnre/7/
这篇关于不同样式的嵌套块引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!