首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在HTML / Bootstrap中连续滚动图像

在HTML / Bootstrap中连续滚动图像
EN

Stack Overflow用户
提问于 2015-07-22 19:27:34
回答 1查看 4.9K关注 0票数 0

我有大约7-8个客户的图像,我想要显示在一个<marquee>标签内。

当最后一个图像和第一个图像有很多间隙时,问题就出现了。我希望图像被显示在一个连续的循环中。

这是我正在使用的HTML代码。

代码语言:javascript
复制
<marquee> 
    <ul>
        <li><a href="#"><img src="img/logo1.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo2.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo3.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo4.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo5.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo6.png" alt=""></a></li>
        <li><a href="#"><img src="img/logo7.png" alt=""></a></li>
    </ul>
</marquee>

我试着在网上搜索,但没有找到相关的答案。

这是我在网上找到的一个样本,但在我的例子中,循环只能工作一次。Sample

EN

回答 1

Stack Overflow用户

发布于 2015-07-22 20:05:11

编辑

这里有一个在HTML5中。

就我个人而言,我会避免使用marquee。

HTML

代码语言:javascript
复制
<div id="captioned-gallery">
    <figure class="slider">

        <figure>
        <img src="http://lorempixel.com/900/50" />
        <figcaption>1</figcaption>
        </figure>

        <figure>
        <img src="http://lorempixel.com/900/50" />
        <figcaption>2</figcaption>
        </figure>

        <figure>
        <img src="http://lorempixel.com/900/50" />
        <figcaption>3</figcaption>
        </figure>

        <figure>
        <img src="http://lorempixel.com/900/50" />
        <figcaption>4</figcaption>
        </figure>

        <figure>
        <img src="http://lorempixel.com/900/50" />
        <figcaption>5</figcaption>
        </figure>

    </figure>
</div>

CSS

代码语言:javascript
复制
@keyframes slidy {
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}

body { margin: 0; } 
div#slider { 
margin: auto;
width: 80%;
max-width: 900px;
border: solid 4px white;
overflow: hidden; }

div#slider figure { 
position: relative;
width: 500%;
margin: 0;
left: 0;
font-size: 0;
animation: 30s slidy infinite; }

div#captioned-gallery { width: 100%; overflow: hidden; }

figure { margin: 0; }

figure.slider {
position: relative; width: 500%;
font-size: 0; animation: 30s slidy infinite; }

figure.slider figure { 
width: 20%; height: auto;
display: inline-block;
position: inherit; }

@media screen and (max-width: 500px) { 
figure.slider figure figcaption { font-size: 1.2rem; }
}

figure.slider figure figcaption {
position: absolute; bottom: -3.5rem;
background: rgba(0,0,0,0.3);
color: #fff; width: 100%;
font-size: 2rem; padding: .6rem;
transition: .5s bottom; }

figure.slider figure:hover figcaption { bottom: 0; }

https://jsfiddle.net/5xrbmaxo/3/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31561800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档