css - 幻灯片图片样式 - css

标签 css slideshow

我这里有这个幻灯片:http://jsfiddle.net/Jtec5/4/
代码:HTML:

<div id="slideshow">
    <div>
        <img src="http://images2.fanpop.com/image/photos/13800000/farrari-sports-cars-13821367-1280-960.jpg">
    </div>
    <div>
        <img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSp3iWMAUsa3krPUVPJnxagcmb86YM59m1mAg6HbBnz_xrZlNr2">
    </div>
    <div>
        <img src="http://images4.fanpop.com/image/photos/17000000/KOENIGSEGG-CCXR-SPECIAL-EDITION-sports-cars-17058415-1920-1440.jpg">
    </div>
></div>
<div id="ul"></div>

CSS:

#slideshow {
    position: relative;
    height: 200px;
    padding: 7px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}
#slideshow > div {
    position: absolute;
    top: 7px;
    left: 7px;
    right: 7px;
    bottom: 7px;
}

#slideshow img {
    width: 100%;
    height: 200px;
    max-width: 100%;
    max-height: 200px;
}
#ul {
    border-radius: 20%;
    width: 50px;
    height: 50px; 
    list-style:none;
    margin:0px;
    padding:0px;
}
#ul li {
    float:left;
    border-radius:10px;
    width:10px;
    height:10px;
    border:1px solid white;
    background:grey;
}
#ul li.active {
    background:black;
}

J查询:

$("#slideshow > div:gt(0)").hide();

var index = 1;
var maxindex = $('#slideshow > div').length;

setInterval(function () {
    $('#slideshow > div:first')
        .fadeOut(1000)
        .next()
        .fadeIn(1000)
        .end()
        .appendTo('#slideshow');
    $('ul li').removeClass('active');
    $('ul li:eq(' + index + ')').addClass('active');
    index = index < maxindex - 1 ? index + 1 : 0;
}, 3000);

for (var i = 0; i < maxindex; i++) {
    $('ul').append('<li class="' + (i == 0 ? 'active' : '') + '"></li>');
}

如您所见,幻灯片中的图片不是很好,它的宽度很高并且看起来很宽,我正在寻找一个切割图片的代码,使其看起来不错并且通常适合幻灯片框的框架

最佳答案

你是说这样?

#slideshow {
  text-align: center;
}

并将#slideshow img 的宽度更改为auto

#slideshow img {
  width: auto;
  height: 200px;
  max-width: 100%;
  max-height: 200px;
}

关于css - 幻灯片图片样式 - css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18240251/

相关文章:

HTML 格式,使我的表单看起来不错

html - 页面顶部三个等距 Logo 的跨浏览器解决方案

javascript - 文本溢出 : ellipsis problems in internet explorer

c# - 以编程方式创建的 UpdatePanel 扩展以填充父容器的最佳实践?

jquery 幻灯片不会循环播放不止一次

javascript - 为什么我的幻灯片无法播放?为什么我的照片消失了?

html - Bootstrap 3 - 超大屏幕背景图片

windows-7 - 如何在 Windows 7 中启动幻灯片桌面更改

jquery - 如何让 jQuery 幻灯片在鼠标悬停时暂停?

jquery - 为什么 IE8 不能正常显示这些透明幻灯片?