使用 Nivo Slider 时,它会将我的图像放大到原始大小的 2 倍左右,这会导致图片看起来很糟糕。我想知道他们是否可以解决这个问题。我的图像尺寸是367 x 246 px
.
这是发生的情况的屏幕:
这是我的带有一些 ERB 的 HTML:
<div class="slider-wrapper up-nivo">
<div id="slider" class="nivoSlider">
<%= image_tag "logo.JPG", alt: "" %>
<%= image_tag "line.JPG", alt: "" %>
<%= image_tag "game.JPG", alt: "" %>
<%= image_tag "leaders.JPG", alt: "" %>
<%= image_tag "crowdFacingJim.JPG", alt: "" %>
<%= image_tag "band.JPG", alt: "" %>
</div>
</div>
然后这是我的CSS:
.nivoSlider {
position:relative;
width:100%;
height:auto;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
}
.nivo-main-image {
display: block !important;
position: relative !important;
width: 100% !important;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
top:0;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
overflow:hidden;
}
.nivo-box img { display:block; }
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
width:100%;
z-index:8;
padding: 5px 10px;
opacity: 0.8;
overflow: hidden;
display: none;
-moz-opacity: 0.8;
filter:alpha(opacity=8);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.nivo-caption p {
padding:5px;
margin:0;
}
.nivo-caption a {
display:inline !important;
}
.nivo-html-caption {
display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav {
text-align:center;
padding: 15px 0;
}
.nivo-controlNav a {
cursor:pointer;
}
.nivo-controlNav a.active {
font-weight:bold;
}
这是我的主题的CSS:
.up-nivo .nivoSlider {
position:relative;
background:#fff url(loading.gif) no-repeat 50% 50%;
margin-bottom:50px;
-webkit-box-shadow: 0px 1px 5px 0px #4a4a4a;
-moz-box-shadow: 0px 1px 5px 0px #4a4a4a;
box-shadow: 0px 1px 5px 0px #4a4a4a;
}
.up-nivo .nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.up-nivo .nivoSlider a {
border:0;
display:block;
}
.up-nivo .nivo-controlNav {
text-align: right;
padding: 20px 0;
line-height: 0;
font-size: 0;
color: transparent;
margin-right: 2.5%;
margin-top: -5%;
}
.up-nivo .nivo-controlNav a {
display:inline-block;
width:16px;
height:16px;
background:url(bulletFull.png) no-repeat;
text-indent:-9999px;
border:0;
margin: 0 2px;
}
.up-nivo .nivo-controlNav a.active {
background:url(bulletEmpty.png) no-repeat;
}
.up-nivo .nivo-directionNav a {
display:block;
height:80px;
width:75px;
text-indent:-9999px;
border:0;
}
.up-nivo a.nivo-nextNav {
background:url(arrowRight.png) no-repeat;
background-position: 50% 50%;
right:15px;
}
.up-nivo a.nivo-prevNav {
background:url(arrowLeft.png) no-repeat;
background-position: 50% 50%;
left:15px;
}
.up-nivo .nivo-caption {
font-family: Helvetica, Arial, sans-serif;
}
.up-nivo .nivo-caption a {
color:#fff;
border-bottom:1px dotted #fff;
}
.up-nivo .nivo-caption a:hover {
color:#fff;
}
.up-nivo .nivo-controlNav.nivo-thumbs-enabled {
width: 100%;
}
.up-nivo .nivo-controlNav.nivo-thumbs-enabled a {
width: auto;
height: auto;
background: none;
margin-bottom: 5px;
}
.up-nivoault .nivo-controlNav.nivo-thumbs-enabled img {
display: block;
width: 120px;
height: auto;
}
这是启动nivo的js:
$(window).load(function() {
return $("#slider").nivoSlider({
pauseTime: 10000,
directionNav: true
});
});