简体   繁体   English

在ASP,C#和CSS中更改图像大小

[英]Change image size in ASP, C# and CSS

Why when I place the mouse on top of the image doesn't change its size? 为什么当我将鼠标放在图像上方时不改变其大小?

I have this on a ASP webpage: 我在ASP网页上有这个:

<asp:Image ID="ProdImage" CssClass="ImgDetail" runat="server" />

The Page_Load() loads the URL of the image like this: Page_Load()像这样加载图像的URL:

ProdImage.ImageUrl = ResolveUrl("~/Images/Products/" + lblProductID.Text + ".jpg");

The CSS ImgDetail class looks like this: CSS ImgDetail类如下所示:

.ImgDetail
{
    width: 180px;
    height: auto; 
}

.ImgDetail:hover
{
    width: 360px;
    height: auto; 
}

I just want to change the image size when the mouse is on top of the image. 我只想在鼠标位于图像上方时更改图像大小。

Thank you. 谢谢。

First debugging step I'd take is confirm that ANY css style you're applying is working. 我要进行的第一步调试是确认您要应用的任何CSS样式都可以正常工作。 So give .ImgDetail a 1px border red or something. 所以给.ImgDetail一个1px的红色边框。 If you don't see it on page load, it means your CSS file isn't being included, which is a common mistake. 如果您在页面加载时没有看到它,则表示您的CSS文件未包含在内,这是一个常见错误。

Kind of solved the problem thanks to @Richthofen idea. @Richthofen的想法有点解决了问题。

I checked the local CSS file ( http://localhost:4290/Styles/Site.css ) during debugging and it didn't have my changes on it. 我在调试过程中检查了本地CSS文件( http://localhost:4290/Styles/Site.css ),但没有更改。

Visual Studio 2010 doesn't update the CSS file when I start its debuger (F5). 启动调试器(F5)时,Visual Studio 2010不会更新CSS文件。 However, it updates the CSS file if I publish the webpage. 但是,如果我发布网页,它将更新CSS文件。

These are the properties of the CSS file on the Visual Studio 2010: 这些是Visual Studio 2010上CSS文件的属性:

Build Action: Content 建立动作:内容

Copy to Output Directory: Copy always 复制到输出目录:始终复制

Closing and opening VS 2010 didn't fix it. 关闭和打开VS 2010并没有修复它。 I had to reboot my PC for the CSS file to have my changes on debugging. 我必须重新启动PC以获取CSS文件才能进行调试更改。 I'm affraid I have to reboot my PC every time I need to debug the CSS file unless anyone knows how to fix this issue. 我很抱歉,每次我需要调试CSS文件时都必须重新启动PC,除非有人知道如何解决此问题。

Thank you. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM