center image on jquery lavalamp menu

585 Views Asked by At

i have a Problem centering an Image. The Adress is

http://burger-laden.de/preview/

As u see there is an menu where the arrow moves. My Problem is now i need that the arrow is always centered of the text. Here the code:

css :

    .navigation .bottom {
    font-weight: bold;
    font-size:16px;
}

.lavaLampBottomStyle {
    position: relative;
    overflow: hidden;
    height: 46px;
}

.lavaLampBottomStyle li {
    float: left;
    list-style: none;
}

.lavaLampBottomStyle li.back {
    background: url(../images/menu_top_arrow.png) no-repeat;
    background-position: left 0px;
    margin-top: 33px;
    margin-left: 20px;
    height: 46px;
    width: auto;
    z-index: 8;
    position: absolute;
}

.lavaLampBottomStyle li a {
    text-decoration: none;
    color: white;
    outline: none;
    text-align: center;
    letter-spacing: 0;
    z-index: 10;
    display: block;
    position: relative;
    overflow: hidden;
    float: left;
    margin: auto 0px;
}  

this is the html

 <ul class="lavaLampBottomStyle" id="1">
                        <li><a href="#">Startseite</a></li>
                        <li class="current"><a href="#">Speisekarte</a></li>
                        <li><a href="#">Anfahrt</a></li>
                        <li><a href="#">Kontakt</a></li>
                    </ul>

and here the lavalamp js

(function($){$.fn.lavaLamp=function(o){o=$.extend({fx:"linear",speed:500,click:function(){}},o||{});return this.each(function(){var b=$(this),noop=function(){},$back=$('<li class="back"><div class="left"></div></li>').appendTo(b),$li=$("li",this),curr=$("li.current",this)[0]||$($li[0]).addClass("current")[0];$li.not(".back").hover(function(){move(this)},noop);$(this).hover(noop,function(){move(curr)});$li.click(function(e){setCurr(this);return o.click.apply(this,[e,this])});setCurr(curr);function setCurr(a){$back.css({"left":a.offsetLeft+"px","width":a.offsetWidth+"px"});curr=a};function move(a){$back.each(function(){$(this).dequeue()}).animate({width:a.offsetWidth,left:a.offsetLeft},o.speed,o.fx)}})}})(jQuery);

thanks

1

There are 1 best solutions below

0
On

I know this is late, however your site actually helped me find this and I am now using it for my new portfolio site I am working on. To achieve the "centered" look please change the following.

.lavaLampBottomStyle li.back {
--- background: url(../images/menu_top_arrow.png) no-repeat;
--- background-position: left center 0px;
--- margin-top: 33px;
--- margin-left: 20px;
--- height: 46px;
--- width: auto;
--- z-index: 8;
--- position: absolute;
}

Because the width is set to auto, the li element fits the same width of the li it is hovering, therefore a simple centered background position does the job.