简体   繁体   English

我的CSS不起作用

[英]My CSS doesn't work

i want to apply the following class to my image element : 我想将以下类应用于我的图像元素:

.laptopimage {
    width: 115px;
    height: 93px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border: 10px solid black;
} 

my code in aspx.cs file : 我在aspx.cs文件中的代码:

Image image=new Image();
image.ImageUrl="~/Images/"+p.ImagePath;
image.CssClass = "laptopimage";

the resulted html code : 产生的html代码:

<img class="laptopimage" src="../Images/Laptop1.jpg"></img>

I can't understand why it doesn't apply css. 我不明白为什么它不适用CSS。 The image is still displayed 1700x1700; 图像仍显示为1700x1700; Can someone explain why this is happening ? 有人可以解释为什么会这样吗?

modify your css and try with this. 修改您的CSS并尝试使用此方法。 Some other css might be overiding your laptopimage class 其他一些CSS可能会覆盖您的laptopimage

.laptopimage {
    width: 115px !important;
    height: 93px !important;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border: 10px solid black;
} 

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

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