473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CSS - image is not showing

Hi,
I have the CSS class below, and the image (pro.gif) is not showing on
my page.
It is showing ONLY where's some text in the div, but all I need is the
image itself.

..pro {background-image: url(/Backpage/Images/pro.gif); display: inline;
}

Am I doing something wrong?

Thanks,
Gabi.

Jul 13 '06 #1
8 2366
Els
Gabriella wrote:
Hi,
I have the CSS class below, and the image (pro.gif) is not showing on
my page.
It is showing ONLY where's some text in the div, but all I need is the
image itself.

.pro {background-image: url(/Backpage/Images/pro.gif); display: inline;
}

Am I doing something wrong?
Yup, you're forgetting to show us the patient :-)

However, a semi-educated guess: a background image is a background to
an element. If that element has no height or width, there is no space
to show that background image. Without seeing what you're doing, I'm
inclined to think you should give ".pro" a width and height to fit
your background-image, and probably a space inside if there is no text
in it.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 13 '06 #2
Gabriella wrote:
I have the CSS class below, and the image (pro.gif) is not showing on
my page.
It is showing ONLY where's some text in the div, but all I need is the
image itself.

.pro {background-image: url(/Backpage/Images/pro.gif); display: inline;
}

Am I doing something wrong?
inline elements with no content have zero size.

Steve

Jul 13 '06 #3
Gabriella wrote:
Hi,
I have the CSS class below, and the image (pro.gif) is not showing on
my page.
It is showing ONLY where's some text in the div, but all I need is the
image itself.

.pro {background-image: url(/Backpage/Images/pro.gif); display: inline;
}
The question is, why are you using a background image when what you
clearly want is an image that appears, not behind other content, but on
its own part of the screen. That's what the IMG tag is for.

Backgrounds don't occupy space, they only appear behind space that's
already occupied. If you have

<div class="pro"></div>

that DIV won't take up any more space in the window than it would
without the background image: none. There isn't anything for the
background image to appear behind. If you have

<div class="pro">abc</div>

then you'll only see as much of the background image as will fit within
the space occupied by the "abc" and the remainder of the DIV's width to
the right of it.
Jul 13 '06 #4
Thanks everyone!
Actually what I want to do is have a <a href...tag with an image that
changes upon hover (onmouseover).

I am using my css "pro" class as follows:
<a href="someurl..." class="pro"></a>
note that it is without content.
My desire is that upon hover, the image will change.
Curretnly, I can't even display the primary image...

I know that I can use this instead:
<a href="someurl..."><img src="/Backpage/Images/pro.gif"
onmouseover="javascript:..."></a>
But I thought there's a more elegant CSS way.
Is there?

Thanks,
Gabi.

Jul 13 '06 #5
Gabriella wrote:
Thanks everyone!
Actually what I want to do is have a <a href...tag with an image that
changes upon hover (onmouseover).

I am using my css "pro" class as follows:
<a href="someurl..." class="pro"></a>
note that it is without content.
My desire is that upon hover, the image will change.
Curretnly, I can't even display the primary image...

I know that I can use this instead:
<a href="someurl..."><img src="/Backpage/Images/pro.gif"
onmouseover="javascript:..."></a>
But I thought there's a more elegant CSS way.
Is there?
The following should work, though if CSS is turned off, both images will
appear. But then, in your approach, if CSS is turned off, then *no*
image appears which means there isn't anything to click.

However, in IE6 it *doesn't* work, and I'm not sure why. I know IE
doesn't recognize :hover on elements *other* than A, I expected it to
work here.

CSS:
a:link img.without-ro,
a:visited img.without-ro { display: inline; }

a:link img.with-ro,
a:visited img.with-ro { display: none; }

a:focus img.without-ro,
a:hover img.without-ro,
a:active img.without-ro { display: none; }

a:focus img.with-ro,
a:hover img.with-ro,
a:active img.with-ro { display: inline; }

HTML:

<a href="..."><img class="without-ro" src="..." ...><img class="with-ro"
src="..." ...></a>
Jul 13 '06 #6
Els
Harlan Messinger wrote:

[hover styles on images in links]
However, in IE6 it *doesn't* work, and I'm not sure why. I know IE
doesn't recognize :hover on elements *other* than A, I expected it to
work here.
It will, if you declare a general a:hover style as well. IE needs the
trigger on the a:hover, to see the styles for "a:hover element".

The general a:hover style must make a difference compared to the
a:link style though, else it still won't work.

Extended explanation:
http://locusoptimus.com/css-trickery...s-on-hover.php

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 13 '06 #7
Els wrote:
Harlan Messinger wrote:

[hover styles on images in links]
>However, in IE6 it *doesn't* work, and I'm not sure why. I know IE
doesn't recognize :hover on elements *other* than A, I expected it to
work here.

It will, if you declare a general a:hover style as well. IE needs the
trigger on the a:hover, to see the styles for "a:hover element".
So weird. I inserted

a:hover { display: inline; }

in front of my other CSS and it works, as you said it would. Thanks.
>
The general a:hover style must make a difference compared to the
a:link style though, else it still won't work.

Extended explanation:
http://locusoptimus.com/css-trickery...s-on-hover.php
Jul 13 '06 #8
Gabriella wrote:
Actually what I want to do is have a <a href...tag with an image that
changes upon hover (onmouseover).

I am using my css "pro" class as follows:
<a href="someurl..." class="pro"></a>
note that it is without content.
My desire is that upon hover, the image will change.
Curretnly, I can't even display the primary image...
If there is no linked text (content of the a element), there is nothing
to select at least in non-visual user agents. If the text is in the
image, the image is not purely decorative, and so must not be in the
CSS, but in HTML instead with an appropriate alt attribute.
--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Jul 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html...
7
by: karthikeyan | last post by:
Hi, I am having some problems hosting my website. Everything works fine in my local machine but when I upload to propduction server, my images won't load properly. I have my state configuration...
10
by: bessington | last post by:
hey all, i'm having a rather bizarre problem.. the image tag i have declared in my xhtml is not showing in safari / konqueror but showing just fine in Firefox, IE, Opera... this is a complete...
9
by: Rajesh | last post by:
Hi all, Im gonna display a list of images in an aspx page from sql server Db.Each image has a link.When someone clicks the image i want the width and size of the image to be displayed at the...
3
by: Mark Szlazak | last post by:
The following page simulates a pool cue and cue ball: http://members.aol.com/myscript/cue.html Mouse cursor position around the cue ball determines where a roll-over of 179 pool cue images is...
7
by: needin4mation | last post by:
Hi, I have an Access 2002 - 2003 database. I am using Access 2003. Whenever I link an image all it shows is the filename. Not the image. Other versions of Access can link the image just fine. ...
0
by: Svein Erik | last post by:
I'm developing an application in C#.NET 2005. The app is going to have an image with a specific size, let's say 800x600 px, this is a map of a go-cart lane. And on top of this image i'm going to...
3
by: Sandeep Singh Sekhon | last post by:
I am developing an application in ASP.NET 1.1. on one page I allow the user to upload and delete the files to the server. When I delete the file, I physically delete the file from the location....
3
by: Switch4Mac | last post by:
Hi, I want to insert an ad in my MasterPage. So in the MasterPage, I have this piece of code: <asp:Image ID="GatesAd" runat="server"...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.