jquery - Flickity: is-selected 类无法查看图片

标签 jquery html css twitter-bootstrap flickity

昨天我有一个用户不友好的轮播。然后我搜索其他灵活且响应迅速的旋转木马解决方案,然后谢天​​谢地我得到了这个 Flickity's carousels a fun to flick by David DeSandro。现在,我在添加图像时遇到了问题。我看不到任何图片。原始文件位于此处 http://codepen.io/desandro/pen/gbjzre .我的代码如下。

<!DOCTYPE html>
<html>

<head>
    <title>Flickity</title>
    <!--Flickity-->
    <link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css">
    <script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>
</head>

<body>
    <div class="gallery js-flickity" data-flickity='{ "autoPlay": true }'>
        <div class="gallery-cell"> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/orange-tree.jpg" alt="orange tree" /></div>
        <div class="gallery-cell"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/submerged.jpg" alt="submerged" /></div>
        <div class="gallery-cell"> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/one-world-trade.jpg" alt="One World Trade" /></div>
        <div class="gallery-cell"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/drizzle.jpg" alt="drizzle" /></div>
        <div class="gallery-cell"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/cat-nose.jpg" alt="cat nose" /></div>
        <div class="gallery-cell"> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/contrail.jpg" alt="contrail" /></div>
        <div class="gallery-cell"> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/golden-hour.jpg" alt="golden hour" /></div>
    </div>
</body>

</html>
<style type="text/css">
/* external css: flickity.css */

* {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
}

.gallery-cell {
    width: 28%;
    height: 200px;
    margin-right: 10px;
    background: #8C8;
    counter-increment: gallery-cell;
}

.gallery-cell.is-selected {
    background: #ED2;
}

/* cell number */

.gallery-cell:before {
    display: block;
    text-align: center;
    content: counter(gallery-cell);
    line-height: 200px;
    font-size: 80px;
    color: white;
}
</style>
<script type="text/javascript">
// external js: flickity.pkgd.js
</script>

最佳答案

感谢 @Ricky 提供以下解决方案,这里是您提供给我的以下解决方案。

第一种方式。我只是删除了 <div class="gallery-cell">相反,我只是添加 class="gallery-cell"里面img元素。

<img class="gallery-cell" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/contrail.jpg" alt="contrail" />

第二个解决方案,我只是在 .gallery-cell:before 中添加代码

.gallery-cell:before {
    display: block;
    text-align: center;
   /* content: counter(gallery-cell);*/
    line-height: 200px;
    font-size: 80px;
    color: white;

    /*@Ricky  2nd Solution*/
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
}

关于jquery - Flickity: is-selected 类无法查看图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43509617/

相关文章:

jquery - 单击菜单外部时使用 jquery 关闭菜单

javascript - 单击选项卡中带有 href 的标签时防止滚动 - Liferay

html - 需要 2 个 100% 宽度的文本框,分为 2 个(50% x 50%)以及一个提交按钮

html - 如何知道 `width`动画中最大的 `translateX`?

CSS - 固定高度 div 的问题

javascript - 在 jquery 中使用我的函数之外的变量

javascript - Jquery 到期倒计时

html - CSS 网格的复杂混合

javascript - 如何使用 js-xlsx 从 HTML 输入中读取文件?

javascript - HTML/JS 形状减法