我在 ASPX 页面上有一个图像控件。我想像 Facebook 一样在上面显示“更改图片”选项。单击它时应该会转到不同的页面。
知道怎么做吗?
最佳答案
试试这段代码
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#profile_pic_wrapper{ position:relative; border:#ccc solid 1px; width:200px; height:200px;}
#profile_pic_wrapper a{ position:absolute; display:none; top:0; right:0; line-height:20px; padding:5px; color:#fff; background-color:#333; text-decoration:underline;}
#profile_pic_wrapper:hover a{ display:block; }
#profile_pic_wrapper:hover a:hover{text-decoration:none;}
.profile_pic{ width:200px; height:200px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="profile_pic_wrapper">
<asp:Image ID="imgProfilePic" runat="server" ImageUrl="profile.jpg" CssClass="profile_pic"/>
<asp:HyperLink ID="lnkChangePicture" runat="server" NavigateUrl="ChangeProfilePic.aspx">Change Picture</asp:HyperLink>
</div>
</div>
</form>
</body>
在上面的示例中,我将 css 样式包含在 aspx 页面中仅用于说明目的。对于现实世界的实现,始终建议将您的样式放在单独的 css 文件中。
关于c# - 将鼠标悬停在图像控件上,例如 asp.net 中的 facebook 图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8328923/