- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Anything Slider,但我无法让图像以相同的尺寸显示。我正在使用 5 张不同尺寸的图像。它们也不会在视口(viewport)中居中。
我已经尝试在 html 中将它们全部调整为相同的大小,并且还更改了 css 中的元素,但我不知道处理这个问题的最佳方法。我已经尝试了我能想到的一切,但我遗漏了一些东西。我对编程还很陌生,所以任何指导都将不胜感激。 http://themusicshop.com/defaultdave3.aspx
这是 fiddle - http://jsfiddle.net/5Kvf5/
HTML:
<ul id="slider3">
<li><a href="summer2008.asp"><img src="http://www.themusicshop.com/images/FinnianRainbowWeb.jpg" alt="" width="400" height="250"></a><div class="caption-bottom">Sing-Dance-Act & Much More!</div></li>
<li><a href="thedailyjoe.asp"><img src="http://www.themusicshop.com/images/DailyJoeBanner.jpg" alt="" width="400" height="250"></a><div class="caption-bottom">Now Serving Breakfast & Lunch</div></li>
<li><a href="plessons.asp"><img src="http://www.themusicshop.com/images/LessonsBanner.jpg" alt="" width="400" height="250"></a><div class="caption-bottom">Private Lessons for All Ages - All Instruments!</div></li>
<li><a href="aeRntplan.aspx"><img src="http://www.themusicshop.com/images/RentalBanner.jpg" alt="" width="400" height="250"></a><div class="caption-bottom">Rent Online in 4 Easy Steps</div></li>
<li><a href="t-store.aspx"><img src="http://www.themusicshop.com/images/StoreBanner.jpg" alt="" width="400" height="250"></a><div class="caption-bottom">Shop Online</div></li>
</ul>
CSS:
/*
AnythingSlider v1.8+ Default theme
By Chris Coyier: http://css-tricks.com
with major improvements by Doug Neiner: http://pixelgraphics.us/
based on work by Remy Sharp: http://jqueryfordesigners.com/
*/
/*****************************
SET DEFAULT DIMENSIONS HERE
*****************************/
/* New in version 1.7+ */
#slider3, slider3 li {
width: 600px;
height: 350px;
list-style: none;
}
/* images with caption */
#slider3 img {
width: 100%;
height: 100%;
}
/* position the panels so the captions appear correctly */
#slider3 .panel { position: relative; }
/* captions */
#slider3 .caption-top, #slider3 .caption-right,
#slider3 .caption-bottom, #slider3 .caption-left {
background: #000;
color: #fff;
padding: 10px;
margin: 0;
position: relative;
z-index: 10;
opacity: 0.65;
filter: alpha(opacity=80);
}
/* Top caption - padding is included in the width (480px here, 500px in the script), same for height */
#slider3 .caption-top {
left: 0;
top: 0;
width: 580px;
height: 30px;
}
/* Right caption - padding is included in the width (130px here, 150px in the script), same for height */
#slider3 .caption-right {
right: 0;
bottom: 0;
width: 130px;
height: 180px;
}
/* Bottom caption - padding is included in the width (480px here, 500px in the script), same for height */
#slider3 .caption-bottom {
left: 0;
bottom: 0;
width: 580px;
height: 30px;
}
/* Left caption - padding is included in the width (130px here, 150px in the script), same for height */
#slider3 .caption-left {
left: 0;
bottom: 0;
width: 130px;
height: 180px;
}
/* Caption close button */
.caption-top .close, .caption-right .close,
.caption-bottom .close, .caption-left .close {
font-size: 80%;
cursor: pointer;
float: right;
display: inline-block;
}
/******************
SET STYLING HERE
******************
=================================
Default state (no keyboard focus)
==================================*/
/* Overall Wrapper */
.anythingSlider-default {
margin: 0 auto;
/* 45px right & left padding for the arrows, 28px @ bottom for navigation */
padding: 0 45px 28px 45px;
}
/* slider window - top & bottom borders, default state */
.anythingSlider-default .anythingWindow {
border-top: 3px solid #777;
border-bottom: 3px solid #777;
}
/* Navigation buttons + start/stop button, default state */
.anythingSlider-default .anythingControls a {
/* top shadow */
background: #777 url(../images/default.png) center -288px repeat-x;
color: #000;
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-radius: 0 0 5px 5px;
}
/* Make sure navigation text is visible */
.anythingSlider-default .anythingControls a span {
visibility: visible;
}
/* Navigation current button, default state */
.anythingSlider-default .anythingControls a.cur {
background: #888;
color: #000;
}
/* start-stop button, stopped, default state */
.anythingSlider-default .anythingControls a.start-stop {
background-color: #040;
color: #ddd;
}
/* start-stop button, playing, default state */
.anythingSlider-default .anythingControls a.start-stop.playing {
background-color: #800;
}
/* start-stop button, default hovered text color (when visible) */
/* hide nav/start-stop background image shadow on hover - makes the button appear to come forward */
.anythingSlider-default .anythingControls a.start-stop:hover, .anythingSlider-default .anythingControls a.start-stop.hover, .anythingSlider-default .anythingControls a.start-stop .anythingControls ul a:hover {
background-image: none;
color: #ddd;
}
/*
=================================
Active State (has keyboard focus)
=================================
*/
/* slider window - top & bottom borders, active state */
.anythingSlider-default.activeSlider .anythingWindow {
border-color: #7C9127;
}
/* Navigation buttons, active state */
.anythingSlider-default.activeSlider .anythingControls a {
/* background image = top shadow */
background-color: #7C9127;
}
/* Navigation current & hovered button, active state */
.anythingSlider-default.activeSlider .anythingControls a.cur, .anythingSlider- default.activeSlider .anythingControls a:hover {
/* background image removed */
background: #7C9127;
}
/* start-stop button, stopped, active state */
.anythingSlider-default.activeSlider .anythingControls a.start-stop {
background-color: #080;
color: #fff;
}
/* start-stop button, playing, active state */
.anythingSlider-default.activeSlider .anythingControls a.start-stop.playing {
background-color: #d00;
color: #fff;
}
/* start-stop button, active slider hovered text color (when visible) */
.anythingSlider-default.activeSlider .start-stop:hover, .anythingSlider- default.activeSlider .start-stop.hover {
color: #fff;
}
/************************
NAVIGATION POSITIONING
************************/
/* Navigation Arrows */
.anythingSlider-default .arrow {
top: 50%;
position: absolute;
display: block;
}
.anythingSlider-default .arrow a {
display: block;
width: 45px;
height: 140px;
margin: -70px 0 0 0; /* half height of image */
text-align: center;
outline: 0;
background: url(../images/default.png) no-repeat;
}
/* back arrow */
.anythingSlider-default .back {
left: 0;
}
.anythingSlider-default .back a {
background-position: left top;
}
.anythingSlider-default .back a:hover, .anythingSlider-default .back a.hover {
background-position: left -140px;
}
/* forward arrow */
.anythingSlider-default .forward {
right: 0;
}
.anythingSlider-default .forward a {
background-position: right top;
}
.anythingSlider-default .forward a:hover, .anythingSlider-default .forward a.hover {
background-position: right -140px;
}
/* Navigation Links */
.anythingSlider-default .anythingControls {
outline: 0;
display: none;
}
.anythingSlider-default .anythingControls ul {
margin: 0;
padding: 0;
float: left;
}
.anythingSlider-default .anythingControls ul li {
display: inline;
}
.anythingSlider-default .anythingControls ul a {
font: 11px/18px Georgia, Serif;
display: inline-block;
text-decoration: none;
padding: 2px 8px;
height: 18px;
margin: 0 5px 0 0;
text-align: center;
outline: 0;
}
/* navigationSize window */
.anythingSlider-default .anythingControls .anythingNavWindow {
overflow: hidden;
float: left;
}
/* Autoplay Start/Stop button */
.anythingSlider-default .anythingControls .start-stop {
padding: 2px 5px;
width: 40px;
text-align: center;
text-decoration: none;
float: right;
z-index: 100;
outline: 0;
}
/***********************
IE8 AND OLDER STYLING
***********************/
/* Navigation Arrows */
.as-oldie .anythingSlider-default .arrow {
top: 30%;
}
.as-oldie .anythingSlider-default .arrow a {
margin: 0;
}
/* margin between nav buttons just looks better */
.as-oldie .anythingSlider-default .anythingControls li {
margin-left: 3px;
}
/* When using the navigationSize option, the side margins need to be zero
None of the navigation panels look good in IE7 now =( */
.as-oldie .anythingSlider-default .anythingControls a {
margin: 0;
}
.as-oldie .anythingSlider-default .anythingNavWindow {
margin: 0 2px;
}
.as-oldie .anythingSlider-default .anythingNavWindow li {
padding: 3px 0 0 0;
}
/***********************
COMMON SLIDER STYLING
***********************/
/* Overall Wrapper */
.anythingSlider {
display: block;
overflow: visible !important;
position: relative;
}
/* anythingSlider viewport window */
.anythingSlider .anythingWindow {
overflow: hidden;
position: relative;
width: 100%;
height: 100%;
}
/* anythingSlider base (original element) */
.anythingSlider .anythingBase {
background: transparent;
list-style: none;
position: absolute;
overflow: visible !important;
top: 0;
left: 0;
margin: 0;
padding: 0;
}
/* Navigation arrow text; indent moved to span inside "a", for IE7;
apparently, a negative text-indent on an "a" link moves the link as well as the text */
.anythingSlider .arrow span {
display: block;
visibility: hidden;
}
/* disabled arrows, hide or reduce opacity: opacity: .5; filter: alpha(opacity=50); */
.anythingSlider .arrow.disabled {
display: none;
}
/* all panels inside the slider; horizontal mode */
.anythingSlider .panel {
background: transparent;
display: block;
overflow: hidden;
float: left;
padding: 0;
margin: 0;
}
/* vertical mode */
.anythingSlider .vertical .panel {
float: none;
}
/* fade mode */
.anythingSlider .fade .panel {
float: none;
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
/* fade mode active page - visible & on top */
.anythingSlider .fade .activePage {
z-index: 1;
}
/***********************
RTL STYLING
***********************/
/* slider autoplay right-to-left, reverse order of nav links to look better */
.anythingSlider.rtl .anythingWindow {
direction: ltr;
unicode-bidi: bidi-override;
}
.anythingSlider.rtl .anythingControls ul {
float: left;
} /* move nav link group to left */
.anythingSlider.rtl .anythingControls ul a {
float: right;
} /* reverse order of nav links */
.anythingSlider.rtl .start-stop { /* float: right; */
} /* move start/stop button - in case you want to switch sides */
/* probably not necessary, but added just in case */
.anythingSlider, .anythingSlider .anythingWindow, .anythingSlider .anythingControls ul a, .anythingSlider .arrow a, .anythingSlider .start-stop {
transition-duration: 0s;
-o-transition-duration: 0s;
-moz-transition-duration: 0s;
-webkit-transition-duration: 0s;
}
最佳答案
我不是 100% 确定你想要什么,但在 this demo ,图像居中(未调整大小):
HTML 模板
<ul id="slider3">
<li>
<div>
<a href="page1.asp">
<img src="image1.jpg" alt="" width="400" height="250">
</a>
<div class="caption-bottom">Caption 1</div>
</div>
</li>
...
</ul>
CSS(使图像居中)
/*
centering css from here:
http://css-tricks.com/centering-in-the-unknown/
*/
ul#slider3 div {
text-align: center;
}
ul#slider3 div:before {
content:'';
display: inline-block;
height: 100%;
vertical-align: middle;
}
ul#slider3 img {
display: inline-block;
vertical-align: middle;
}
脚本
showCaptions = function ($this) {
$this.find('.caption-bottom')
.show()
.animate({
bottom: 0,
opacity: 1
}, 400);
};
hideCaptions = function ($this) {
$this.find('.caption-bottom')
.stop()
.animate({
bottom: -50,
opacity: 0
}, 350, function () {
$this.find('.caption-bottom').hide();
});
};
$('#slider3')
.anythingSlider()
/* this code will make the caption appear when you hover over the panel
remove the extra statements if you don't have captions in that location */
.find('.panel')
.find('div[class*=caption]').css({
position: 'absolute'
}).end()
.hover(function () {
showCaptions($(this))
}, function () {
hideCaptions($(this));
});
// hide all captions initially
hideCaptions($('#slider3 .panel'));
更新:要调整窗口大小,在整个 slider 周围添加一个包装器,设置其最大尺寸大小,然后包括 expand
和 aspectRatio
选项 ( updated demo ) :
CSS
.wrapper {
width: 100%;
height: 500px;
}
修改后的脚本
$('#slider3')
.anythingSlider({
expand: true,
aspectRatio : 600/350
})
关于jquery - Anything Slider - 使用不同尺寸的图像和字幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21393908/
我正在尝试使用 div 和 javascript 创建一个简单的 slider 。我设置了一个包含六个图像的 div 和一个箭头,每次单击它时,该箭头都会将包含图像的容器拍摄为 528px(每个图像的
我使用flexslider,当我按照他们网站上的说明操作时,它不适用于多个 slider ,这是代码: 我需要在两个 slider 上都有一个 Controller 导航,说明如下: http://w
这是一个困难的问题,我一直在努力让它发挥作用。它确实起作用了一半,但我认为逻辑是问题所在。下面我会解释一下情况和问题。 情况:想要使用 slider Controller 来选择房间内可以占用的成人、
我制作了一个简单的 slider ,它适用于普通表格,但是当我尝试将该 slider 用于我的自定义 Bootstrap 表格时,只有第一个、第三个 slider 出现,而不是第二个和第四个。 var
我正在使用 Bootstrap slider http://seiyria.com/bootstrap-slider/对于贷款产生者。这里没问题。 但是我必须使用相同的 slider ,一个位于顶部,
我正在使用光滑的 slider 。我在页面上有三个 slider ,它们都有相同的类和光滑的选项。但是,我想要三个不同的灵活“autoplaySpeed”选项,或者为所有三个 slider 分别添加随
我试图用 Slider2 和 Slider3 的总和来更新 Slider1 的值,但它只显示 Slider1 或 Slider2 的值,以移动的为准。我在更新 Slider1 的值时犯了一些错误。 H
我使用 css 和 html 以及 jQuery 创建了一个 slider 。该 slider 与下一个按钮配合使用效果很好,但与上一个按钮配合使用效果不佳。 假设我在第一张幻灯片上有五个元素,总共有
我正在制作一个包含多个 slider 的页面,其中 slider 的数量和选项根据用户的不同而不同。我遇到一个问题,所有 slider 都已创建并显示,但只有最后一个 slider 是可拖动的。 简单
我正在尝试获取 jQuery-UI slider 的当前值在 JavaScript 函数中,它不起作用。如果我这样做 $("#someParticularDOMObject").find(".sl
我正在尝试在 JQuery UI 中的 slider 的 slide 和 change 事件上同时更新多个 slider 。 我有如下代码: $(function() { var totalS
我正在使用来自 Filament 组的 jQuery UI slider ,它将 SELECT 元素转换为 slider 。它工作正常。现在我想使用 JavaScript 以编程方式将 slider
是否可以在 NIVO SLIDER 中将幻灯片设为链接? 最佳答案 嗯,不知道是不是一样,但是...... 我在 IE 所有版本中的链接都有问题,其他浏览器工作正常,通过添加解决: backgroun
在我的项目中,我使用了光滑的 slider 插件(http://kenwheeler.github.io/slick/) 我需要更改单词的默认点导航。单击单词后应更改幻灯片。 最佳答案 这是更新的代码
我正在使用 nivo slider (默认主题),我将上一个和下一个箭头定位在图像旁边(不是在图像顶部),我想知道是否有一种方法可以始终显示下一个和上一个箭头(现在箭头仅在您将鼠标悬停在图像上时显示)
我正在使用 Slider在我的 javaFX 项目中,我有一个 Label当我移动 slider 时会更新。 我想要 Label在我拖动 Slider 时进行更新不仅在拖放时。 这是我的代码: be
我有一个事件站点,一页上有 3 个光滑的 slider ,通常光滑的 slider 不会初始化,而是我只看到所有的图像,有时如果我刷新它们都开始工作。 https://au.hairandme.com
我想让每年一定数量的海龟(由 slider 控制)死亡。到目前为止,我明白了,它可能非常简单,但我似乎无法使其发挥作用。多谢! to hunting let huntedturtles (count
我有一个带背景图像的全宽 slider 。 slider 高度根据图像进行响应,因此它始终在屏幕的一侧到另一侧显示 100% 的图像。 现在我尝试将内容(文本)放置在 slider 内,使其位于内容网
我对 Swiper slider 有一些问题。当我滚动到 slider 的末尾时,可以看到一些空白区域。 http://take.ms/siqXj swiper = new Swiper(profil
我是一名优秀的程序员,十分优秀!