更改URL的默认颜色代码

Change the default color code of URL

本文关键字:颜色 代码 默认 URL 更改      更新时间:2023-09-26

好友我想将下面URL的默认蓝色更改为红色,我尝试使用style="color:红色,但没用。请提出一个更好的方法。

<div class="row-fluid">
    <div class="span12" style="color:red"><a href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalNotSentRecipient)}</a>
    </div>
</div>

您需要编辑实际的元素。你可以通过多种方式做到这一点。

在您的CSS文件中(这将编辑所有链接)

a:active, a:link, a:visited {
    color: red;
}

使用内联样式

将样式直接应用于a元素。

<a style="color: red" ...

或者,在CSS文件中创建一个类

您可以在CSS文件中创建一个类:

a.myLink:active, a.myLink:link, a.myLink:visited {
    color: red;
}

然后将类应用于您的链接:

<a class="myLink" ...

我看到您的<a>链接有类"underline"。你可以将这个css代码添加到你的css文件中,使文本变成红色:

.underline a:active, .underline a:link, .underline a:visited {
    color: red;
}

或者直接在HTML中应用,比如:

<div class="row-fluid">
    <div class="span12"><a style="color:red" href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalNotSentRecipient)}</a>
    </div>
</div>

您将颜色应用于div,需要更改acolor,而不是div

实时演示

<div class="row-fluid"><div class="span12" ><a style="color:red" href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalNotSentRecipient)}</a></div></div>

通常,使用css类是一种很好的做法,而不是使用样式属性直接更改样式

CSS

.red-color-a
{
   color:red;
}

HTML

<div class="row-fluid"><div class="span12" ><a class="red-color-a" href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalNotSentRecipient)}</a></div></div>

您需要以<a>标记为目标,而不是其父span:

<a style="color:red"> ... </a>

锚点标记的默认样式将覆盖包装它的<span>标记。

使用文本装饰none

<a href="http://www.google.com" style="text-decoration:none;color:red">Visit google</a>