【问题标题】:CSS Change the Arrows in Fullpage.js to custom images?CSS 将 Fullpage.js 中的箭头更改为自定义图像?
【发布时间】:2015-04-11 21:36:07
【问题描述】:

我正在使用 fullpageJS https://github.com/alvarotrigo/fullPage.js/ 来制作我的网站。我想更改箭头以显示自定义图像。我发现这个问题之前在这里问过CSS: change arrows on fullpage JS?,我试图用我自己的 arrows.css 样式覆盖 jquery.fullPage.css 并且没有显示图像。我对编码比较陌生,所以我不确定覆盖原始 css 的最佳方法。

箭头的原始css:

.fp-controlArrow {
    position: absolute;
    z-index: 4;
    top: 50%;
    cursor: pointer;
    width: 0;
    height: 0;
    border-style: solid;
    margin-top: -38px;
    -webkit-transform: translate3d(0,0,0);
    -ms-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
}
.fp-controlArrow.fp-prev {
    left: 15px;
    width: 0;
    border-width: 38.5px 34px 38.5px 0;
    border-color: transparent #fff transparent transparent;
}
.fp-controlArrow.fp-next {
    right: 15px;
    border-width: 38.5px 0 38.5px 34px;
    border-color: transparent transparent transparent #fff;
}

我的 arrows.css 样式代码:

.fp-controlArrow {
    position: absolute;
    width:146px !important;
    height:286px !important;
    z-index: 4;
    top: 50%;
}
.fp-controlArrow.fp-prev {
    background-image: url(images/leftnavbutton.png) !important;
    background-repeat: no-repeat;
    left: 0px;
    height:286px;
    width: 146px;
    z-index: 10; 
}
.fp-controlArrow.fp-next {
    background-image: url(images/rightnavbutton.png) !important;
    background-repeat: no-repeat;
    right: 0px;
    height:286px;
    width:146px;
    z-index: 10;
}

【问题讨论】:

    标签: javascript jquery html css fullpage.js


    【解决方案1】:

    改用这样的代码:

    .fp-controlArrow {
        position: absolute;
        width: 128px; /* This can be added here so you don't have to set a width and height 2 times for each arrow, this will create one width for both arrows */
        height: 128px; /* This does the same as above */
        margin-top:-64px; /* This value must always be half of the height - This does the same as above */
        z-index: 4;
        top: 50%;
        cursor: pointer;
    }
    
    .fp-controlArrow.fp-prev {
        left:0;
        background: url(images/rightnavbutton.png) no-repeat;
    }
    .fp-controlArrow.fp-next {
        right:0;
        background: url(images/rightnavbutton.png) no-repeat;
    }
    

    【讨论】:

    • 确实使代码更整洁,但我的图像仍然没有显示在原始箭头的位置。有没有更好的方法来覆盖 css?
    • 可能是因为您没有将 background URL 指向正确的 URL 路径。我已经在 J​​sfiddle 上对此进行了测试,它工作得很好。我无法在此处粘贴 Jsfiddle 文件,因为在 Jsfiddle 上保存所有 FullpageJS 代码时存在问题。它不接受保存我不知道为什么
    • 这里。尝试用这个background: url(http://www.mricons.com/store/png/110949_27865_128_play_right%20arrow_icon.png) no-repeat; 替换这个background: url(images/rightnavbutton.png) no-repeat;,你会看到图像出现。这是我测试时使用的图像
    • 是的,这就是问题所在,修复了路径并且它可以工作。非常感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    • 2016-09-17
    • 2013-11-02
    相关资源
    最近更新 更多