Jarren Ong Jarren Ong - 1 month ago 4
ASP.NET (C#) Question

Image display in css, html

for some reason I can't wrap my head around CSS and HTML.
I'm trying to get an image to display for a HTML div in my Master page. I'm using Visual Studio and they are in different files.

HTML:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div class="image" href="/css/masterCSS.css">

</div>
<form id="form1" runat="server">
<div>
<br />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>


CSS:

div.image {
content:url(http://i.imgur.com/6d3unPC.jpg)
}


Files:

enter image description here

I tried runat="server" on the div and it didn't change anything.

Answer

If I corectly understand what you wanna do try this way:

<div class="image">
 <a href="/css/masterCSS.css">
 <img src="insert path to your image">
</a>

This is a method that doesent require CSS to ad content... in case you stil wanna do it that way just use your CSS and in my HTML code delte 3rd line...

I hope that helps :)