html - jQuery background-image fadeIn -
I am trying to feed a background image in my list item. I've tried everything but it was not found ...
HTML:
& Lt; P id = "text1" & gt; Text & lt; / P & gt; & Lt; / Li & gt; ($ ('#Een'). CSS ("background-f"
You will need to create a background IMG element that is fully located within a relative parent.
< P> Here is an example of what I mean.
HTML Notice I add a div to it with the first item in each li Class as li-background . This is done by CSS This will not be edited to be shown on load and will be fully deployed within the parent, which is relatively a situation. I have also set my z-index <1> to -1, this lesson or No other item is displayed in Li, so its background! gt; & lt; li id = "een" & gt; & Lt; div class = "li-background" & gt; & lt; img src = "http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /> Lt; / Div & gt; & Lt; H1 & gt; Title & lt; / H1> & Lt; P id = "text1" & gt; Text & lt; / P & gt; & Lt; / Li & gt; & Lt; Li id = "een" & gt; & Lt; Div class = "li-background" & gt; & Lt; Img src = "http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /> & Lt; / Div & gt; & Lt; H1 & gt; Title 2 & lt; / H1> & Lt; P id = "text1" & gt; Text 2 & lt; / P & gt; & Lt; / Li & gt; & Lt; Li id = "een" & gt; & Lt; Div class = "li-background" & gt; & Lt; Img src = "http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /> & Lt; / Div & gt; & Lt; H1 & gt; Title3 & lt; / H1> & Lt; P id = "text1" & gt; Text 3 & lt; / P & gt; & Lt; / Li & gt; & Lt; Li id = "een" & gt; & Lt; Div class = "li-background" & gt; & Lt; Img src = "http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /> & Lt; / Div & gt; & Lt; H1 & gt; Title4 & lt; / H1> & Lt; P id = "text1" & gt; Text 4 & lt; / P & gt; & Lt; / Li & gt; & Lt; / Ul & gt; CSS ul li {status: relative; } Ul li: hover {color: white; } .li-background {display: none; Height: 100%; Left: 0; Status: Completed; Top: 0; Width: 100%; Z-index: -1; } .li-background img {height: 100%; Width: 100%; } jq script $ ("li"). Hover (function (eIn) {$ (this). Children (".lib-background"). Stop () .FadeIn ();}, function (eOut) {$ (this). Child ("Li-background" ). Stop () .Fed Out ();});
Comments
Post a Comment