【问题标题】:Display Details of dish when hovering over image ASP.NET将鼠标悬停在图像 ASP.NET 上时显示菜肴的详细信息
【发布时间】:2015-03-17 05:59:27
【问题描述】:

我的页面上有许多图片,我希望在页面旁边显示一些注释/评论/详细信息,说明当它们悬停在任何特定图片上时图片的用途。

这是餐厅项目。当有人将鼠标悬停在图像上时,它会显示菜肴文字描述。

我将如何实现这一目标?

(我正在寻找类似于您将鼠标悬停在此 stackoverflow 页面下面的标签上时...)

body 
{
}

/* Image Box Style */
#mainwrapper .box {
	border: 5px solid #fff;
	cursor: pointer;
	height: 100px;
	float: left;
	margin: 5px;
	position: relative;
	overflow: hidden;
	width: 100px;
		-webkit-box-shadow: 1px 1px 1px 1px #ccc;
		-moz-box-shadow: 1px 1px 1px 1px #ccc;
		box-shadow: 1px 1px 1px 1px #ccc;
}
#mainwrapper .box img {
	position: absolute;
	left: 0;
		-webkit-transition: all 300ms ease-out;
		-moz-transition: all 300ms ease-out;
		-o-transition: all 300ms ease-out;
		-ms-transition: all 300ms ease-out;	
	transition: all 300ms ease-out;
}

/* Caption Common Style */
#mainwrapper .box .caption {
	background-color: rgba(0,0,0,0.8);
	position: absolute;
	color: #fff;
	z-index: 100;
		-webkit-transition: all 300ms ease-out;
		-moz-transition: all 300ms ease-out;
		-o-transition: all 300ms ease-out;
		-ms-transition: all 300ms ease-out;	
		transition: all 300ms ease-out;
	left: 0;
}

/** Caption 3: Fade **/
#mainwrapper .box .fade-caption
{
	opacity: 0;
	width: 100px;
	height: 100px;
	text-align: left;
	padding: 0px;
}

/** Fade Caption :hover Behaviour **/
#mainwrapper .box:hover .fade-caption
{
	opacity: 1;
}
<div id="mainwrapper">
    <div id="box-3" class="box">
        <asp:Image ID="Image1" CssClass="dishimg" runat="server" Width="100px" Height="100px" ImageUrl='<%# Bind("Image","~/Images/{0}") %>' />
        <span class="caption fade-caption" >
            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Comment") %>'></asp:Label>
        </span>
    </div>

【问题讨论】:

  • 您是否尝试过任何方法,或者您是否希望 Stack Overflow 为您完成工作
  • 我尝试了一些东西,但是当数据变得更多时,文本会溢出。以前我试过图像。但它对我不起作用。
  • 显示您对问题的尝试,并告诉我们预期的输出是什么,以便我们查看哪里出了问题
  • 用代码@Jcl更新问题

标签: asp.net image hover


【解决方案1】:

你可以在图片标签中使用title属性。鼠标悬停时将显示标题。例如:

<img src="smiley.gif" alt="Smiley face" width="42" height="42" title ='test'>

【讨论】:

  • 你也试过这个,但我的图像尺寸很小,高度 100:px 宽度:100px 但我想要更多的文字。我们可以说菜的小描述@qamar
  • 您尝试在标题中使用更多文字吗?怎么样?
  • &lt;asp:Image ID="Image1" CssClass="dishimg" runat="server" Width="100px" Height="100px" ImageUrl='&lt;%# Bind("mage","~/Images/{0}") %&gt;' ToolTip='&lt;%# Eval("Com") %&gt;' 如果数据越多则不显示,表示字符数在 200 左右
  • 我试过很长的标题,当鼠标悬停在图像上时它会显示出来。请看这里:jsfiddle.net/#&togetherjs=RoHDQ9H32G
猜你喜欢
  • 2021-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-19
相关资源
最近更新 更多