开发者

CSS Styling for 'a' (anchor tag) is not working

开发者 https://www.devze.com 2023-03-31 12:55 出处:网络
Let\'s say I have some hyperlink but class and id of it are already used by other scripts. So how can I add some css to them ? I tried 2 things.

Let's say I have some hyperlink but class and id of it are already used by other scripts. So how can I add some css to them ? I tried 2 things.

<div class='some_css'>
<a href='".$_SERVER['PHP_SELF']."' class='used' id='used1'>link1</a>
<a href='".$_SERVER['PHP_SELF']."' class='used' id='used2'>link2</a>
</div>

///css file
.some_css:a
{
color:#456e9c;
}

Another try

<span class='some_css'><a href='".$_SERVER['PHP_SELF']."' class='used' id='used1'>link1</a></span>
<span class='some_css'><a href='".$_SERVER['PHP_SELF']."' class='used' id='used2'>link2</a></span>

///css file   
.some_css:a
{
color:#456e9c;
}

Both are wrong..... I know I do something wrong, p开发者_运维百科lease help


Use a space, not a colon (:). Colons are meant for stuff like pseudo-classes/elements, and properties.

.some_css a
{
color:#456e9c;
}


replace the colon (':') by a space.


.some_css a {

}

(in other words, lose the ':')


Target a contained inside .some_css

.some_css a {
  color:#456e9c;
}


a href='".$_SERVER['PHP_SELF']."' class='used other_class' id='used1'>link1</a>

So you can define more than one class to an element with using space as a seperator...

0

精彩评论

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

关注公众号