简体   繁体   中英

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 :

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

the resulted html code :

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

I can't understand why it doesn't apply css. The image is still displayed 1700x1700; Can someone explain why this is happening ?

modify your css and try with this. Some other css might be overiding your laptopimage class

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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