CSS Hover+Background Image -


i'm creating special ui control using html/css mimic windows 7 control panel buttons. far, i've got layout right , i'd add cosmetics it.

as seen here, there gradient appears when hover on button mouse.

http://m.cncfps.com/zack/files/this-control.png

now, can see here i've got layout done. i'd add :hover effect whole div item background image.

currently, here have css- yet doesn't work. no image shows in ie8, or firefox

edit: works in chrome, not in firefox or ie.

#cp .cp-item:hover {     background:url(images/hoverbg.png) repeat-x; } 

it work background-color rather image.

  • there's nothing (relevant) wrong css.
  • the path image correct.

it works in chrome.

chrome seems more intelligent (or lenient) other browsers. if inspect page, it's inserting stuff:

enter image description here

it doesn't work in other browsers because don't have proper page structure (no doctype, no <html> tag, no <body> tag, etc) - page doesn't validate, , other browsers not "like it". don't know exact reason why doesn't work other browsers - imagine reason either implementation detail, or buried within w3 spec.

this works in "all browsers":

live demo
(i'm using <base> tag make paths work)

it's exact code, wrapped in typical boilerplate, addition of <base> tag.

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>  <base href="http://toro.azwestern.edu/~zbl/" />  <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head>  <body>  <link rel="stylesheet" href="style.css" type="text/css" />  <div id="cp">     <div class="cp-item"><span>         <div class="cp-item-icon"><img src="images/syssec.png" title="system , security" /></div>         <div class="cp-item-content">             <h4>system , security</h4>             <ul>                 <li><a href="#">item</a></li>                  <li><a href="#">item</a></li>                 <li><a href="#">item</a></li>                 <li><a href="#">item</a></li>                 <li><a href="#">item</a></li>                 <li><a href="#">item</a></li>             </ul>          </div>     </span></div> </div>  </body> </html> 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -