CSS和JS - 将背景图像扩展到div之外

时间:2012-07-02 20:33:52

标签: javascript css background-image

我目前正在尝试找到一种解决方法,在Niall Doherty的Coda Slider 2上使用箭头来突出显示所选标签。最初我尝试使用标题图像上的图像进行此操作,虽然在Mac上的Safari中看起来很好,但它并不是其他设备的核心(请参阅www.lukekendalldesign.co.uk/pss/productsandservices

我尝试使用CSS箭头创建它但事实证明相当困难,所以我找到了使用背景图像的解决方法,但我遇到了另一个问题。

http://cl.ly/HovO(抱歉,我无法上传图片 - 新手!)

请参阅上面的链接截图。与背景匹配的较浅灰色三角形是标题图像的一部分。使用以下CSS代码定位黑色三角形:

.coda-nav ul li a.current { 
    border-top-right-radius: 10px; 
    border-top-left-radius: 10px; 
    color: white;
    height: 60px; 
    z-index: 20000;
    background: url(../images/triangle.png) no-repeat 50% 100%;
    position: relative;
    overflow: visible;
}

我正在尝试做的是将这个黑色箭头放在灰色图像箭头的位置(如果这有意义吗?)我该怎么做?

我尝试过添加边距和填充,但是它会扩展灰色背景并且不会将背景图像黑色三角形向下推。

虽然我发现类似的解决方案,但似乎没有适用,因为使用以下JS应用类.current:

// If we need a tabbed nav
    $('#coda-nav-' + sliderCount + ' a').each(function(z) {
        // What happens when a nav link is clicked
        $(this).bind("click", function() {
            navClicks++;
            $(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
            offset = - (panelWidth*z);
            alterPanelHeight(z);
            currentPanel = z + 1;
            $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
            if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
        });
    });

我非常感谢任何人可以提供给我的任何帮助 - 因为这是一个JS问题,这有点超出我的深度! :(

1 个答案:

答案 0 :(得分:0)

我在Firefox上使用Windows上的火虫试过这个。我认为有两个问题。第一个是ul元素上的边距应该是167px(黑色箭头不是图像中的一个好位置(中间是232 px你的意思是这个?)。 箭头只需要向下移动,我将背景位置设置为: url(“../ images / triangle.png”)无重复滚动50px 60px透明希望这会有所帮助。

相关问题