Hyperlink Image in CSS or skin for theme

Posted on 2007-11-20
Last Modified: 2008-02-01
I've created several themes using css and skins.

In my master page, I want to have the logo dependent upon the current theme being used. So within each theme directory, I have a logo named: Logo.gif

Currently, I just have this within the master page.

                        <a href="<%= ResolveClientUrl("~/default.asp")%>">
                    <img src='<%= ResolveClientUrl("logo.gif")%>' width='228'
                                height='77' style='border: none'></a></td>

How do I change it to setup the logo.gif within the skin or style sheet, and then display it (hyperlinked as above) within my master page?

Question by:Starr Duskk
  • 2
  • 2
LVL 29

Accepted Solution

Göran Andersson earned 500 total points
ID: 20325913
If you specify the image as a background in the css, the browser will get the image relative to the css file instead of relative to the page.

If you put the logo image in the theme filder where the css file is, this will use it:

.Logo { width: 228px; height: 77px; background: url(logo.gif); }


<a href="<%= ResolveClientUrl("~/default.asp")%>" class="Logo"></a>

Open in new window


Author Comment

by:Starr Duskk
ID: 20326031
hmmm. I tried this:

<asp:HyperLink ID="HyperLink1" runat="server" CssClass="Logo" NavigateUrl="~/Default.aspx">[HyperLink1]</asp:HyperLink>

and this:

<a href="<%= ResolveClientUrl("~/default.asp")%>" class="Logo"></a>

This does display the logo, but no hyperlink:

                    <div class="Logo"></div>

What am I doing wrong?


LVL 29

Assisted Solution

by:Göran Andersson
Göran Andersson earned 500 total points
ID: 20326054
Ah, I missed that the link has to be a block element in order for one to specify the size.
.Logo { display: block; width: 228px; height: 77px; background: url(logo.gif); }

Open in new window


Author Comment

by:Starr Duskk
ID: 20330230
yay, thanks!

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Issue 3 85
Host pages 5 25
Remove greater than sign 3 42
What .NET URL re-routing tool did I use? 2 36
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now