jquery - 实现 jQuery 照片幻灯片时遇到问题

标签 jquery html css jquery-ui slider

我正在尝试在我的网站中实现一个 jquery 图像幻灯片,但由于不是我自己创建的,所以我无法识别所有的 css 属性。我遇到的三个问题是:

1) 当图像滚动时,有一个父容器延伸到幻灯片面板的宽度之外。 2) 我已经调整了每个属性的边距和填充,但我无法让图像周围的黑色填充消失。 3) 我不知道如何调整图像之间的空间。

在这里您可以看到图像周围的黑色填充:

enter image description here

在这里您可以看到图像之间的边距和漂浮在容器外的图像:

enter image description here

带有放大镜的栏是我的 IDE 的一部分。

下面是运行 slider 的 HTML:

        <div class="slider">
            <div id="header">
                <div class="wrap">
                    <div id="slide-holder">
                        <div id="slide-runner">
                            <a href=""><img id="slide-img-1" src="images/nature-photo.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-2" src="images/nature-photo1.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-3" src="images/nature-photo2.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-4" src="images/nature-photo3.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-5" src="images/nature-photo4.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-6" src="images/nature-photo4.png" class="slide" alt="" /></a>
                            <a href=""><img id="slide-img-7" src="images/nature-photo6.png" class="slide" alt="" /></a> 
                            <div id="slide-controls">
                                 <p id="slide-client" class="text"><strong>post: </strong><span></span></p>
                                 <p id="slide-desc" class="text"></p>
                                 <p id="slide-nav"></p>
                            </div>
                        </div>  
                    </div>
                    <script type="text/javascript">
                            if(!window.slider) var slider={};slider.data=[
                                    {"id":"slide-img-1","client":"nature beauty","desc":"nature beauty photography"},
                                    {"id":"slide-img-2","client":"nature beauty","desc":"add your description here"},
                                    {"id":"slide-img-3","client":"nature beauty","desc":"add your description here"},
                                    {"id":"slide-img-4","client":"nature beauty","desc":"add your description here"},
                                    {"id":"slide-img-5","client":"nature beauty","desc":"add your description here"},
                                    {"id":"slide-img-6","client":"nature beauty","desc":"add your description here"},
                                    {"id":"slide-img-7","client":"nature beauty","desc":"add your description here"}
                                ];
                    </script>
                </div>
            </div>
        </div>

这是 CSS:

* {
    margin : 0;
    padding : 0;
}

html {
    height : 100%;
}

div.slider {
    height : 100%;
    color : #a4a4a4;
    cursor : default;
    font-size : 11px;
    line-height : 16px;
    text-align : center;
    background-position : 50% 0;
    background-repeat : no-repeat;
    font-family : Tahoma, sans-serif;
    background-color: black;
}



a:link, a:visited {
    color : #fff;
    text-decoration : none;
}
a img {
    width: 92%;
}
div.wrap {
    text-align : left;
}
div#top div#nav {
    float : left;
    clear : both;
    width : 993px;
    height : 52px;
}
div#top div#nav ul {
    float : left;
    width : 700px;
    height : 52px;
    list-style-type : none;
}
div#nav ul li {
    float : left;
    height : 52px;
}
div#nav ul li a {
    border : 0;
    height : 52px;
    display : block;
    line-height : 52px;
    text-indent : -9999px;
}
div#header {
    margin : -1px 0 0;
}
div#video-header {
    height : 683px;
    margin : -1px 0 0;
}
div#header div.wrap {
    /* image height */
    height : 300px;
    background : url(images/header-bg.png) no-repeat 50% 0;
}
div#header div#slide-holder {
    /* slider container */
    z-index : 40;
    width : 915px;
    height : 299px;
    position : absolute;
}
div#header div#slide-holder div#slide-runner {
    top : 9px;
    left : 9px;
    width : 973px;
    height : 278px;
    overflow : hidden;
    position : absolute;
}
div#header div#slide-holder img {
    margin : 0;
    display : none;
    position : absolute;
}
div#header div#slide-holder div#slide-controls {
    left : 0;
    top: 0;
    width : inherit;
    height : 46px;
    width: 896px;
    display : none;
    position : absolute;
    background-color: rgba(0,0,0, .5);
}
div#header div#slide-holder div#slide-controls p.text {
    float : left;
    color : #fff;
    display : inline;
    font-size : 10px;
    line-height : 16px;
    margin-top: 13px;
}
div#header div#slide-holder div#slide-controls p#slide-nav {
    /* page numbers */
    float : right;
    height : 24px;
    display : inline;
    margin : 11px 15px 0 0;
}
div#header div#slide-holder div#slide-controls p#slide-nav a {
    float : left;
    width : 24px;
    height : 24px;
    display : inline;
    font-size : 11px;
    margin : 0 5px 0 0;
    line-height : 24px;
    font-weight : bold;
    text-align : center;
    text-decoration : none;
    background-position : 0 0;
    background-repeat : no-repeat;
}
div#header div#slide-holder div#slide-controls p#slide-nav a.on {
    background-position : 0 -24px;
}
div#header div#slide-holder div#slide-controls p#slide-nav a {
    background-image : url(images/slide-nav.png);
}
div#nav ul li a {
    background : url(images/nav-bg.png) no-repeat;
}

我知道仅通过查看标记可能很难看出来,但是对 CSS 有敏锐眼光的人有没有看出问题所在?

最佳答案

问题出在 scripts.js 文件中,您将图片放置在相距 1000 的位置。如果图片宽度为 1000 像素,则它们之间不会有任何空间。您必须更改图片宽度或 scripts.js 中的代码(大约第 86 和 113 行)。

关于jquery - 实现 jQuery 照片幻灯片时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5217148/

相关文章:

javascript - 单击段落中的单词后如何获得到目前为止的字数?

javascript - 带有 jQ​​uery 函数的 CSS 动画有延迟时间

html - CSS3 border-radius 在 Visual Studio 元素中的呈现方式与在 HTML 文件中的呈现方式不同

html - 嵌入 OpenType 字体文件

用于响应式设计的 HTML 大小单位

css - 为什么 !important 被覆盖了?

jquery - 从使用全宽背景图像的现有标记创建 Bootstrap 轮播

jquery mobile css 不从本地加载,只能从 web 加载

css - 像 Chrome 一样更改 Mozilla 和 I.E 中的滚动条格式

html - 如何根据父高度/宽度的变化调整内部元素?