在添加Font-Awesome后,Slick Carousel箭头被截断了

4
我正在为我的网站Peruvian Connection设计一个走马灯。我需要为箭头设置样式。于是我在stackoverflow论坛上寻找答案并发现可以使用Font-Awesome及其Unicode来改变箭头的形状和外观(主题在这里: How to style prev/next arrows button?)。更改图标后,它们在Chrome中完美地工作。然而,在IE中它们被裁剪,而且在其他浏览器中有点故障。我研究了这个问题并发现它是由于箭头字体大小造成的。
你可以在这里找到演示: http://www.peruvianconnection.com/category/ads/lookbook.do?test=test 测试过的浏览器:

Chrome-完美运行
Safari-稍微有一些故障
Firefox-只能在特定区域工作。
IE 9,10,11-箭头被裁剪。

这是Slick-Theme.css的代码:
    @charset 'UTF-8';
/* Slider */
.slick-loading .slick-list
{
    background: #fff url('./ajax-loader.gif') center center no-repeat;
}

/* Icons */
@font-face
{
    font-family: 'slick';
    font-weight: normal;
    font-style: normal;

    src: url('./fonts/slick.eot');
    src: url('./fonts/slick.eot?#iefix') format('embedded-opentype'), url('./fonts/slick.woff') format('woff'), url('./fonts/slick.ttf') format('truetype'), url('./fonts/slick.svg#slick') format('svg');
}
/* Arrows */

.slick-prev:before, .slick-next:before { font-family: FontAwesome; }

.slick-prev,
.slick-next
{
    font-size: 0;
    line-height: 0;

    position: absolute;
    top: 50%;

    display: block;

    width: 20px;
    height: 20px;
    margin-top: -10px;
    padding: 0;

    cursor: pointer;

    color: transparent;
    border: none;
    outline: none;
    background: transparent;
}
.slick-prev:hover,
.slick-prev:focus,
.slick-next:hover,
.slick-next:focus
{
    color:transparent;
    outline: none;
    background: transparent;
}
.slick-prev:hover:before,
.slick-prev:focus:before,
.slick-next:hover:before,
.slick-next:focus:before
{
    opacity: 1;
}
.slick-prev.slick-disabled:before,
.slick-next.slick-disabled:before
{
    opacity: .25;
}

.slick-prev:before,
.slick-next:before
{
    font-family: FontAwesome; 
    font-size: 40px;
    line-height: 1;
    opacity: .75;
    color: brown;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.slick-prev
{
    left: -25px;
}
[dir='rtl'] .slick-prev
{
    right: -25px;
    left: auto;
}
.slick-prev:before
{
    content: "\f0d9"; 
}
[dir='rtl'] .slick-prev:before
{
   content: "\f0d9";
}

.slick-next
{
    right: -25px;
}
[dir='rtl'] .slick-next
{
    right: auto;
    left: -25px;
}
.slick-next:before
{
    content: "\f0da";
}
[dir='rtl'] .slick-next:before
{
    content: content: "\f0da";
}

/* Dots */
.slick-slider
{
    margin-bottom: 30px;
}

.slick-dots
{
    position: absolute;
    bottom: -45px;

    display: block;

    width: 100%;
    padding: 0;

    list-style: none;

    text-align: center;
}
.slick-dots li
{
    position: relative;

    display: inline-block;

    width: 20px;
    height: 20px;
    margin: 0 5px;
    padding: 0;

    cursor: pointer;
}
.slick-dots li button
{
    font-size: 0;
    line-height: 0;

    display: block;

    width: 20px;
    height: 20px;
    padding: 5px;

    cursor: pointer;

    color: transparent;
    border: 0;
    outline: none;
    background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus
{
    outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before
{
    opacity: 1;
}
.slick-dots li button:before
{
    font-family: 'slick';
    font-size: 6px;
    line-height: 20px;

    position: absolute;
    top: 0;
    left: 0;

    width: 20px;
    height: 20px;

    content: '•';
    text-align: center;

    opacity: .25;
    color: black;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.slick-dots li.slick-active button:before
{
    opacity: .75;
    color: black;
}
2个回答

6

在你的slick-theme.css文件中删除第33和34行,即:

width: 20px;
height: 20px;

已经在IE11上测试,希望它也能在其他浏览器上正常工作。


2
确实是这样的 ;) - Stefan Neuenschwander
感谢您的测试。我在其他浏览器中测试过了,似乎完美地工作。非常感谢。 - Sourumeiji
是的 @StefanNeuenschwander ;) - Mohsin Raza

1

移除 .slick-prev 和 .slick-next 上的 width:20px; 和 height:20px;,这样就可以正常工作了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接