473,403 Members | 2,359 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,403 software developers and data experts.

Set background-position in class and background-image in id.

I want to set a background-image with an id and use class to create
the rollover effect by altering background-position.

It wont work in either IE or FF. Any suggestions?

HTML
<a href="#" id="knappKalender" class ="knapp" (...)
CSS
a.knapp {
height:105px;
width:105px;
background-position: top left;
}

a.knapp:hover, a.knapp:focus {
background-position:center left;
}

a.knapp:active {
background-position:bottom left;
}

a#knappKalender {
background:url(../images/knapp_kalender.jpg) no-repeat;
}
Nov 30 '07 #1
3 3571
On Fri, 30 Nov 2007 15:30:00 +0100, <to*******************@gmail.com
wrote:
I want to set a background-image with an id and use class to create
the rollover effect by altering background-position.

It wont work in either IE or FF. Any suggestions?

HTML
<a href="#" id="knappKalender" class ="knapp" (...)
CSS
a.knapp {
height:105px;
width:105px;
background-position: top left;
}

a.knapp:hover, a.knapp:focus {
background-position:center left;
}

a.knapp:active {
background-position:bottom left;
}

a#knappKalender {
background:url(../images/knapp_kalender.jpg) no-repeat;
}
I you use 'background-image:url(..);' instead of 'background:' it will
work in Opera & FF, MSIE (7) will not cooperate it seems.
--
Rik Wasmus
Nov 30 '07 #2
On 30 Nov, 19:14, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Fri, 30 Nov 2007 15:30:00 +0100, <tor.brekke.skjotsk...@gmail.com>
wrote:


I want to set a background-image with an id and use class to create
the rollover effect by altering background-position.
It wont work in either IE or FF. Any suggestions?
HTML
<a href="#" id="knappKalender" class ="knapp" (...)
CSS
a.knapp {
height:105px;
width:105px;
background-position: top left;
}
a.knapp:hover, a.knapp:focus {
background-position:center left;
}
a.knapp:active {
background-position:bottom left;
}
a#knappKalender {
background:url(../images/knapp_kalender.jpg) no-repeat;
}

I you use 'background-image:url(..);' instead of 'background:' it will
work in Opera & FF, MSIE (7) will not cooperate it seems.
--
Rik Wasmus- Skjul sitert tekst -

- Vis sitert tekst -
Thanks!

Actually it worked with IE7 as well. I'm yet to test with IE6 and I do
not have high expectations :-)

Regards
Tor
Nov 30 '07 #3
On Fri, 30 Nov 2007 22:24:00 +0100, <to*******************@gmail.com
wrote:
On 30 Nov, 19:14, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>On Fri, 30 Nov 2007 15:30:00 +0100, <tor.brekke.skjotsk...@gmail.com>
wrote:
I want to set a background-image with an id and use class to create
the rollover effect by altering background-position.
It wont work in either IE or FF. Any suggestions?
HTML
<a href="#" id="knappKalender" class ="knapp" (...)
CSS
a.knapp {
height:105px;
width:105px;
background-position: top left;
}
a.knapp:hover, a.knapp:focus {
background-position:center left;
}
a.knapp:active {
background-position:bottom left;
}
a#knappKalender {
background:url(../images/knapp_kalender.jpg) no-repeat;
}

I you use 'background-image:url(..);' instead of 'background:' it will
work in Opera & FF, MSIE (7) will not cooperate it seems.

Thanks!

Actually it worked with IE7 as well. I'm yet to test with IE6 and I do
not have high expectations :-)
D'oh! Offcourse, in MSIE 7 it does work, provided the <ahas an href
attribute..
--
Rik Wasmus
Dec 1 '07 #4

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

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
0
by: Ken Lee | last post by:
Hi all, I'm sort of very new to C# and haven't programmed in OO for a while. I'm trying to override the backgroundimage to the tabcontrol but it just doesn't seem to want to do it, can someone...
0
by: kidzero | last post by:
Hello Is here any way to set ListView control background image ? I tried to override listview class BackgroundImage property but no effect. ListView still display simple color :( Maritn.
14
by: Dino M. Buljubasic | last post by:
I would like to be able to compare BackgroundImage Property of two picture boxes on my form. How can I do that? I am using : if (pctOne.BackgroundImage Is pctTwo.BackgroundImage) then //...
1
by: kjon | last post by:
Hi, I'm trying to get the BackgroundImage of a form/control and draw it again in runtime. But if the Backgroundimage is "None", the DrawImage command will give an error. Is it possible to...
1
by: John | last post by:
Hello all, I was wondering, does this property really exist in VB.NET 2003? Because it's listed in Intellisense, but setting it doesn't seem to have the slightest effect on the visual look of...
1
by: VB Programmer | last post by:
I am trying to check which image is currently the BackgroundImage (VB.NET 2005). Can you help me out? Me.BackgroundImage.ToString doesn't work. Here's the sample code... Select Case...
12
by: Sharon | last post by:
I’m using a Panel control in my form to display a background image. So in the Form OnPaint() I wrote: myPanel.BackgroundImage = m_bmp; While the m_bmp is the Form Bitmap member. The problem...
3
by: fehays | last post by:
Hello, Can someone please tell me why this code leaks? The handle count for IE continues to increase. var newimage = "url(images/" + res.value.Image + ")"; if( imagetd.style.backgroundImage...
2
by: OBAFGKM_RNS | last post by:
When I added an image to a css layer, to center it horizontally, I used 50%. Now, in my javascript, I need to be able to determine what that x position is in pixels. How can I do this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.