将 CSS 应用到我的 ASP.net LinkBut​​ton

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1317106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:59:07  来源:igfitidea点击:

Applying CSS to my ASP.net LinkButton

asp.netcss

提问by Sergio Tapia

How can I accomplish this?

我怎样才能做到这一点?

My CSS:

我的CSS:

.MainMenu
{
    position: absolute;
    top:135px;
    left:15px;    
    background-color: #033E6B;
    color:White;
    border-style:double;
    border-color:White;
}

.MainMenu ul
{
    list-style-type:none;
    padding-left:3px;
    padding-right:3px;
}

My UserControl Code:

我的用户控制代码:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MainMenu.ascx.cs" Inherits="LoCompro.UserControls.MainMenu" %>
<ul>
    <li><asp:LinkButton ID="LinkButton4" runat="server">Inicio</asp:LinkButton></li>
    <li><asp:LinkButton ID="LinkButton1" runat="server">Navegar Por Categoria</asp:LinkButton></li>
    <li><asp:LinkButton ID="LinkButton2" runat="server">Navegar Por Marca</asp:LinkButton></li>
    <li><asp:LinkButton ID="LinkButton3" runat="server">Buscar</asp:LinkButton></li>
</ul>

And my MasterPage:

还有我的母版页:

<div class="MainMenu">
            <uc2:MainMenu ID="MainMenu1" runat="server" />
        </div>

My intention is go modify the way my links appear. I want them to be white color, turn yellow on hover and never change even if they click on it/have visited before.

我的意图是去修改我的链接出现的方式。我希望它们是白色的,悬停时变成黄色,即使他们点击它/以前访问过也永远不会改变。

I don't know how to work with LinkButtons, today's my first time. :)

我不知道如何使用 LinkBut​​tons,今天是我第一次。:)

Thanks guys!

谢谢你们!

回答by Andy Gaskell

This should be pretty close.

这应该非常接近。

.MainMenu a { 
  color: #FFF;
}

.MainMenu a:active 
{

}

.MainMenu a:visited 
{

}

.MainMenu a:hover { 
  color:#FFFF00;
}

回答by Kevin LaBranche

Give the link buttons a CssClass="nameofclass" which is a property of the linkbutton

给链接按钮一个 CssClass="nameofclass" 这是链接按钮的一个属性

In your css then:

在你的 css 中:

.nameofclass
{

}
.nameofclass a
{

}

回答by Matthew Talbert

You can use the CssClass property of a LinkButton to add a css class to them.

您可以使用 LinkBut​​ton 的 CssClass 属性向它们添加 css 类。

<asp:LinkButton ID="LinkButton1" CssClass="buttonClass" runat="sever">

Then just make a css class "buttonClass" in your css file.

然后只需在您的 css 文件中创建一个 css 类“buttonClass”。

.buttonClass
{
}

回答by Himalaya Garg

a.mylink
{
    color: #990000;
    text-decoration:none;
}

a:hover.mylink
{
    color: #990000;
    text-decoration:underline;
}

You will find it useful...

你会发现它很有用...