【问题标题】:Change my Link colors with CSS in asp.net在 asp.net 中使用 CSS 更改我的链接颜色
【发布时间】:2020-03-12 19:52:17
【问题描述】:

我需要一些帮助来更改我的链接颜色。这是目前我的 asp.net 代码。

<div class="tile">
        <div class="first">
            <b>Links</b>
            <div class="links">
                <asp:HyperLink ID="hyperlink1" NavigateUrl="#ss" Text="Phone List" CssClass="linkbutton" runat="server" />
                <br />
                <asp:HyperLink ID="hyperlink2" NavigateUrl="#ff" Text="FAQ" CssClass="linkbutton" runat="server" />
                <br />
                <asp:HyperLink ID="PMOLink" NavigateUrl="/PMO/PMO.aspx" Text="PMO" CssClass="linkbutton" runat="server" />
                <br />
                <asp:HyperLink ID="PMLink" NavigateUrl="/PM/PM.aspx" Text="PM" CssClass="linkbutton" runat="server" />
            </div>
        </div>
        <br />
    </div>

这是我的 CSS 代码。

.first {
    float: left;
    height: 100%;
    width: 10%;
    text-align: left;
}

.links {
    display: block;
    text-align: left;
    height: 109px;
    width: 251px;
}

.tile {
    border-style: solid;
    padding: 14px;
    border-width: 3px;
    color: black;
    display: inline-block;
    height: 130px;
    list-style-type: none;
    margin: 10px 40px 10px 20px;
    position: relative;
    text-align: left;
    width: 270px;
    border-radius: 25px;
    box-shadow: 10px 10px 5px #888888;
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #CCF11B), color-stop(1, #3874FF));
    background-image: linear-gradient(-28deg, #CCF11B 0%, #3874FF 100%);
    vertical-align: top;
    text-align: center;
}

/* Change the Links colors here!*/
linkbutton:link {
    text-decoration: none;
    color: blue;
}

linkbutton:visited {
    text-decoration: none;
    color: blue;
}

linkbutton:hover {
    text-decoration: underline;
    color: blue;
}

linkbutton:active {
    text-decoration: underline;
    color: blue;

我的结果应该是当我将鼠标悬停在链接上时,转到上述链接,一般来说只是链接,它们应该保持相同的颜色并且永远不会改变。我还被告知它更容易使用 CSS 然后 C#。请问我能得到一些帮助吗!

【问题讨论】:

    标签: html css asp.net


    【解决方案1】:

    在您的 CSS 中,您需要在链接按钮类之前添加点:

    .linkbutton:link {
        text-decoration: none;
        color: blue;
    }
    
    .linkbutton:visited {
        text-decoration: none;
        color: blue;
    }
    
    .linkbutton:hover {
        text-decoration: underline;
        color: blue;
    }
    
    .linkbutton:active {
        text-decoration: underline;
        color: blue;
    

    【讨论】:

    • 非常感谢。不敢相信我忘记了。
    • 不客气。 :) 它可能发生在每个人身上。我记得花了两个小时对某些程序进行故障排除,以找出缺少一个分号。编码的乐趣……
    猜你喜欢
    • 1970-01-01
    • 2016-06-04
    • 2013-06-10
    • 1970-01-01
    • 2013-02-13
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 2011-01-24
    相关资源
    最近更新 更多