how do you set css to add an asp img?

2020-04-19 05:55发布

问题:

how do you set css to add an asp img?

I need to control the size of the image within the div aswell and its alignment? Preferably to the right and make it 15% of the size inside the div?

Any of this possible?

div#test {
width:90%; 
z-index:1; 
padding:27.5px; 
border-top: thin solid #736F6E;
border-bottom: thin solid #736F6E;
color:#ffffff;
margin:0 auto;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
word-wrap: break-word;
}

回答1:

Chances are no.

If you mean an image server control (either <asp:Image> or `) CSS is a client-side technology while any Asp.NET server controls are server-side. (keyword: in server controls is server ;) )

If you mean an HTML image (<img> with no runat="server") then no again. You'd use JavaScript to do this: CSS cannot add elements (things with tags like <img>) to the document. It can add text context using the content property but not elements like <img>.

Lastly, if you mean give "the div" a background image, yes, CSS can do this, using the background-image property... but I don't think you can resize background images. Maybe with CSS3... I'm not sure.