Home >Web Front-end >HTML Tutorial >I would like to ask an expert, how to set individual styles for many paragraphs? _html/css_WEB-ITnose
Hello everyone, I would like to ask, I have a paragraph of text, there are many e388a4556c0f65e1904146cc1a846bee
I now set a separate class for the first e388a4556c0f65e1904146cc1a846bee, using the first-child method Let's set the first e388a4556c0f65e1904146cc1a846bee.
But now I want to set the style for the second paragraph, or all the remaining paragraphs. How to set it? What method to use.
I want to implement it like this. The style of the first p is class1, and the styles of the remaining p are all class2.
Does anyone here know how?
p.className("class2");
Set the class separately for the first e388a4556c0f65e1904146cc1a846bee, using first-child This method is used for the first e388a4556c0f65e1904146cc1a846bee
What about the other p? How to set the style? 9f90f44faa32e17cb35196e9e25635b0content94b3e26ee717c64999d7867364b1b4a3
The other p is603eb80375aadfb3d40be23abc9e88c5content94b3e26ee717c64999d7867364b1b4a3
<!doctype html><html><head><meta charset="gb2312"><title>无标题文档</title><style type="text/css">p:first-child { background-color:#CCC}p { background-color:#ABC}</style></head><body><p>1</p><p>2</p><p>3</p><p>4</p></body></html>because my js is To control whether all articles are displayed or only part of them, class="p_detail"
is set like this. After running, look at the source code
or e388a4556c0f65e1904146cc1a846bee
There is no 9f90f44faa32e17cb35196e9e25635b0
<html><head><meta charset="gb2312"><title>无标题文档</title><style type="text/css">.p_detail { background-color:#CCC}.p_excerpt { background-color:#ABC}</style><script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script><script type="text/javascript">$(document).ready(function(e) { $("p:first-child").addClass("p_detail") $("p:not(:first-child)").addClass("p_excerpt")});</script></head> <body><p>1</p><p>2</p><p>3</p><p>4</p></body></html>It’s not available when you look at the source code, but it’s actually there! Use firefox or chrome to view it by pressing F12.