开发者

styling a div with a specific ID

开发者 https://www.devze.com 2023-04-12 15:24 出处:网络
#contentp开发者_JS百科age div Does this mean select the div that has id #contentpage? I am getting some bad layout.I am trying to select the div with the id #contentpage.

#contentp开发者_JS百科age div

Does this mean select the div that has id #contentpage?

I am getting some bad layout. I am trying to select the div with the id #contentpage.

Could somebody also please tell me what the following css mean:

#myid div a
.myid a h
div #myid a


#myid div a
<anytag id="myid"><div><a rel="match">...

.myid a h
<anytag class="myid"><a><h rel="match">...

div #myid a
<div><anytag id="myid"><a rel="match">...

If you would like to match a div with id #myid, then either ignore the fact that it's a div (ids are unique anyway) or match it as follows:

div#myid


#myid div a

This will match an a within a div within an element with the id of myid. When I say "within" I mean anywhere within at any nesting level. The others are all the same but with different elements in different orders.


If you want an element with the id of contentpage you simply use #contentpage. If for some reason you wanted to specify that it was a div it would be div#contentpage.


if you want to modify the styling of the div with the id of contentpage then you would do the following

div#contentpage { //input styling here }

OR

#contentpage { //input styling here }

it also looks like you are trying to get at elements under the div these can be accessed in a number of ways but this is usually what I do

<div id="contentpage"><div><a></a></div></div>

#contentpage a { //stying }
#contentpage div a {  //styling }


#contentpage {color:red} will select whichever element with id contentPage

#myid div a will select <a> elements that are inside <div> that are inside an element with id myid

.myid a h as far as I know there is no <h> element ? Without the h, it would select all links within any elements with the class myid (in this case myid is a dubious name, then, since its not an id per se)

div #myid a will select links inside of an element with id myid, but only if this element is within a <div>. It won't work if the element myid is a direct children of <body> for example

0

精彩评论

暂无评论...
验证码 换一张
取 消