如何将css样式应用于标记?(How to apply css styles to a tag?)

编程入门 行业动态 更新时间:2024-10-21 03:32:30
如何将css样式应用于标记?(How to apply css styles to a tag?)

我的html里面有一个标签<i> 。 我已经在HTML中的所有<a>标签中应用了一些样式。 但我想分隔<i>标签中的任何<a>标签。 我该怎么做?

a.aCategory:link { color: #000000; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aSubCategory:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a:link { color: #3B73B9; text-decoration: none; } a:visited { color: #3B73B9; text-decoration: none; } a:active { color: #3B73B9; text-decoration: none; } a:hover { color: #064D6E; text-decoration: underline; }

谢谢。

I have a tag in my html inside <i>. I am already applying some styles to all <a> tags in my HTML. But i would like to separate any <a> tag which is in an <i> tag. How can I do it?

a.aCategory:link { color: #000000; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } a.aSubCategory:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a.aSubCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } a:link { color: #3B73B9; text-decoration: none; } a:visited { color: #3B73B9; text-decoration: none; } a:active { color: #3B73B9; text-decoration: none; } a:hover { color: #064D6E; text-decoration: underline; }

Thanks.

最满意答案

第一件事是在标签内添加不同的风格我只使用'ia'代表所有后代,或者'i> a'代表i的直接孩子。

第二件事是你应该在为所有标签编写的样式之后编写此样式。

a.aCategory:link { color: #000000; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:link{ //enter your style here } a.aCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:visited{ //enter your style here } a.aCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:active{ //enter your style here } a.aCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:hover{ //enter your style here } a.aSubCategory:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:link{ //enter your style here } a.aSubCategory:visited { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:visited{ //enter your style here } a.aSubCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:active{ //enter your style here } a.aSubCategory:hover { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:hover{ //enter your style here } a:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:link{ //enter your style here } a:visited { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:visited{ //enter your style here } a:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:active{ //enter your style here } a:hover { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:hover{ //enter your style here }

注意:在上面的代码中,如果您想要仅为子标签应用不同的样式,如果我标记,则使用i> a代替。

First thing is to add different style to a tag inside i just use 'i a' for all descendant or 'i > a' for direct child a of i.

Second thing is you should write this style after style you have written for all a tag.

a.aCategory:link { color: #000000; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:link{ //enter your style here } a.aCategory:visited { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:visited{ //enter your style here } a.aCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:active{ //enter your style here } a.aCategory:hover { color: #999999; text-decoration: none; font-family: Arial; font-size: 12px; font-weight: bold; } i a.aCategory:hover{ //enter your style here } a.aSubCategory:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:link{ //enter your style here } a.aSubCategory:visited { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:visited{ //enter your style here } a.aSubCategory:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:active{ //enter your style here } a.aSubCategory:hover { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a.aSubCategory:hover{ //enter your style here } a:link { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:link{ //enter your style here } a:visited { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:visited{ //enter your style here } a:active { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:active{ //enter your style here } a:hover { color: #000000; text-decoration: none; font-family: Arial; font-size: 11px; font-weight: bold; } i a:hover{ //enter your style here }

NOTE : in above code if you want to apply different style for only child a tag if i tag then use i > a instead.

更多推荐

本文发布于:2023-08-07 09:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463735.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用于   如何将   样式   标记   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!