开发者

change css id into a class

I got the following 开发者_JAVA百科css:

#navlist li #current
{
  color: #000;
  background: #FFFFFF;
  border-bottom: 1px solid #FFFFFF;
}

I need to change that #current element into a class in order to assign it dynamically to the right li.

How can I translate the code above into a .current with the same result and still applying only to #navlist li elements.

I'm really not good at css and I'm not sure how to write this. (I've tried ways without much success)


EDIT: The code below should work.

#navlist li {
    color: #000;
    background: #FFFFFF;
    border-bottom: 1px solid #FFFFFF;
}


I'm not sure I understand your question, but the main difference between IDs and classes is that IDs have to be unique in your page. So as long as there is only one element with the id="current", everything is fine. If you need more than one, change it to class="current" for all of them.

In CSS, you will set properties for the ID with #current {...} and for the class(es) with .current {...}

Hope it helps.

Update: Depending on your HTML structure, what you need is either #navlist li.current (for li's with the class current) or #navlist li .current (for child elements - like a div - of li's). In this case the CSS will apply ONLY to elements with class current inside the navlist div.


Try:

#navlist li {
   // styles here
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜