PHP file has a paragraph: <div class= "Post-alt blog" id= "Post-alt" >
There is a section in the CSS file:
. Post-alt {XXXXXX}
. Blog {XXXXXX}
There are two questions: 1, the DIV layer definition has class,id, so the final CSS format definition to listen to who?
2, CSS does not have "#post-alt{xxx} This ID format definition, then the ID in this div what role?"
When the ID and class appear in the code ... Listen to the ID first. After listening to class ....
But your code doesn't show the style of the ID ... So listen to class. But your code is a little bit more special. is class= "Post-alt blog". The meaning of this writing is. It has 2 class. If you specify more than 2 classes for an element: To be separated by a space ...
Your CSS is. Post-alt. Blogs usually appear in more than 2 classes. is to divide the situation ... Like what.. If there are no duplicate definition styles. Then listen to all the collections ... If there are duplicates ... Like what
. post-alt{font-size:12px;font-family:arial;}
. blog{font-size:20px;}
The final style is {font-size:20px;font-family:arial;}
Just listen to the blog .... Other words... The style in the first class is in the 2nd style if not: Just listen to this property in the first style ... The same property listens to the 2nd style. Then set the properties of these 2:
But if you specify an ID: The ID has the same attributes as the class: Then listen to the ID ...
Question 2: This inside it was not defined #post-alt all ... The ID of the div inside is not defined ... You may be depressed why define an ID ... The ID doesn't have to be used in CSS ... It is indicated that: A page. The only one element ... 2 Identical IDs cannot appear on a page ... However, there can be n identical classes ..... Like what.. Use JS.. When you combine the DOM to get the only element in a page ... We can use the ID to get ... Such as:
var Post_alt=document.getelementbyid ("Post-alt");
This means getting the element with ID post-alt in the page. That's the div you're writing, you can do some things with this div. Such as:
Post_alt.style.background= "#ff0099";
Then.. The color of this layer becomes magenta ...
Reference:
Http://zhidao.baidu.com/question/121122095.html?qbl=relate_question_3&word=css%20id%20class
Http://www.codefans.net/jscss/code/586.shtml