Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: DIV i hover, niezgodność z Validatorem
Forum PHP.pl > Forum > Po stronie przeglądarki > CSS
3miel
Witam,

mam w stronce taki fragment tekstu:
Kod
<div class="mg_l" onMouseOver="this.style.backgroundColor='#CDE288';" onMouseOut="this.style.backgroundColor='';"><a href="#">...</a></div>


i validator wywala taki bład:
Error Line 32 column 30: there is no attribute "onMouseOver".
<div class="mg_l" onMouseOver="this.style.backgroundColor='#CDE288';" onMouseOut
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.


Domyślam się że należy zrobić taki sam efekt ale przy użyciu stylów, tylko jak zrobić w stylach, że po najechaniu na div, zmieni sie jego tlo? .mg_l:hover nie działa.
sobstel
po pierwsze nie napisales jak masz zdefiniowany doument? html? xhtml? strict? transitional? to kluczowa kwestia

pod rugie, najprawdopodobniej chodzi zeby onmouseout i onmouseover pisac malymi literami... (xhtml)
3miel
Takie to proste smile.gif Myślałem że jednak to będzie coś innego i nawet nie chciało mi się sprawdzać czy to jest wielkość liter.

Dzięki, już jest wszystko OK smile.gif
Zajec
Kolejny przykład zbędnego użycia JS?

  1. <div class="mg_l">
  2. <a href="</span>">...</a>
  3. <<span style='color:blue'>/div>
Kod
.mg_l a {
display: block;
bakcground-color: transparent;
}
.mg_l a:hover {
bakcground-color: #cde288;
}
Działa w każdej przeglądarce i nie wymaga włączonego JavaScript.
gulldarek
Zajec - zakladasz, ze umiescil tam tylko <a>, a mogl umiescic wiele roznych elementow.
mike
A ostatnio właśnie znalazłem sposób na pseudoklasę hover tak aby działała dla każdego elementu pod bardzIEwIEm

whatever:hover
gulldarek
mike_mech: właśnie powiększyłeś moją liste IE hacków o kolejny element snitch.gif

Zakładki mi w szwach pękają winksmiley.jpg
Zajec
Cytat(gulldarek @ 2005-12-10 23:32:55)
Zajec - zakladasz, ze umiescil tam tylko <a>, a mogl umiescic wiele roznych elementow.

I dlatego dałem znak zapytania i kulturalnie wytłumaczyłem :-)
skl
Witam
To moj pierwszy post na forum wiec chcialem sie przywitac. I jednoczesnie zadac pytanie.
Jeszcze raczkuje w css , robie pierwsza swoja strone. Jest juz na finiszu, tylko pojawily sie problemy z IE :|

jednym z problemow jest onmouseover Zrobilem to w xhtmlu w ten sposob:

Kod
<a class="link" href="index.php?pokaz=domyslna" onmouseover='domyslna.src="menu_04b.jpg"'onmouseout='domyslna.src="menu_04.jpg"'><img height="29" name="domyslna" id="domyslna" src="menu_04.jpg" width="210" align="top" border="0"></a>


Dziala pod ff. Pod IE wyskakuje komunikat, ze IE zablokowal aktywna zawartosc strony poniewaz jest niebezpieczna. Czytalem hack podany przez mike_mech , jednak jako, ze css jest dla mnei jeszcze niedostatecznie zrozumialy, to css opisywany po angielsku tym bardziej :| Czy jest jakis sposob by to inaczej napisac, tak zeby dzialalo z MSIE?
Zajec
Przede wszystkim w drzewie DOM nie ma czegoś takiego jak "domyslna". Odwołuj się do elementów w dokumencie przez np. id.

Kod
document.getElementById('identyfikator').src='blabla';


Zauważ, że wielkość liter (np. w getElementById) jest istotna.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.