简体   繁体   English

响应式HTML CSS滑块问题

[英]Responsive HTML CSS slider problems

I've just copied this codepen to my page. 我刚刚将此代码笔复制到了我的页面。

It works well, but I have some other content on my page as well, and the problem is that when I import this code, it destroys all links and other images on my page. 它运作良好,但是我的页面上还有其他内容,问题是当我导入此代码时,它会破坏页面上的所有链接和其他图像。 Does anyone know why is this happening, and how to solve this? 有谁知道为什么会这样,如何解决呢? :) :)

HTML HTML

<base href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/">
<div id="slider">
<figure>
<img src="austin-fireworks.jpg" alt>
<img src="taj-mahal_copy.jpg" alt>
<img src="ibiza.jpg" alt>
<img src="ankor-wat.jpg" alt>
<img src="austin-fireworks.jpg" alt>
</figure>
</div>

CSS CSS

@keyframes slidy {
0% { left: 0%; }
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 { overflow: hidden; }
div#slider figure img { width: 20%; float: left; }
div#slider figure { 
  position: relative;
  width: 500%;
  margin: 0;
  left: 0;
  text-align: left;
  font-size: 0;
  animation: 30s slidy infinite; 
}

It probably destroys all links and everything else because of 由于以下原因,它可能会破坏所有链接和其他所有内容

<base href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/">

Which will make it so that your links and references are based on off of that. 这样可以使您的链接和引用基于此。 As per mozilla developers : 根据mozilla开发人员

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document. HTML <base>元素指定用于文档中包含的所有相对URL的基本URL。 There can be only one element in a document. 文档中只能有一个元素。

Solution for you case in particular: 特别适合您的解决方案:

Remove that base href element on top of your page, and update the sources for each image in the slider individually for its absolute URL. 删除页面顶部的基本href元素,并分别为其绝对URL更新滑块中每个图像的源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM