- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在元素中使用 Unslider ( http://unslider.com/ )。
我成功地将整个 slider 部分对准了目标的一半。但问题是1920 和更低宽度分辨率的幻灯片没有居中。图片的宽度为 3940 像素。
我尝试应用来自 this 的代码回答;像这样:
$(function () {
$('.banner').unslider();
AdjustSliderImgWrapper();
});
$(window).resize(AdjustSliderImgWrapper);
function AdjustSliderImgWrapper() {
var left = (parseInt($('.banner > li > img').width()) - $('.banner > li').innerWidth()) / -2;
$('.banner > li > img').css('left', left);
}
,但无济于事。我也试过:
$(".banner img").each(function () {
$(this).css("margin-left", -this.width / 2);
})
还有:
background-position: center center !important;
这是我的代码:
window.console && console.warn("This version of Unslider is due to be deprecated by December 1. Please visit unslider.com for details on how to upgrade."), function (t, s) {
if (!t)
return s;
var i = function () {
this.el = s,
this.items = s,
this.sizes = [],
this.max = [0, 0],
this.current = 0,
this.interval = s,
this.opts = {
speed : 500,
delay : 3e3,
complete : s,
keys : !s,
dots : s,
fluid : s
};
var i = this;
this.init = function (s, i) {
return this.el = s,
this.ul = s.children("ul"),
this.max = [s.outerWidth(), s.outerHeight()],
this.items = this.ul.children("li").each(this.calculate),
this.opts = t.extend(this.opts, i),
this.setup(),
this
},
this.calculate = function (s) {
var e = t(this),
n = e.outerWidth(),
h = e.outerHeight();
i.sizes[s] = [n, h],
n > i.max[0] && (i.max[0] = n),
h > i.max[1] && (i.max[1] = h)
},
this.setup = function () {
if (this.el.css({
overflow : "hidden",
width : i.max[0],
height : this.items.first().outerHeight()
}), this.ul.css({
width : 100 * this.items.length + "%",
position : "relative"
}), this.items.css("width", 100 / this.items.length + "%"), this.opts.delay !== s && (this.start(), this.el.hover(this.stop, this.start)), this.opts.keys && t(document).keydown(this.keys), this.opts.dots && this.dots(), this.opts.fluid) {
var e = function () {
i.el.css("width", Math.min(Math.round(i.el.outerWidth() / i.el.parent().outerWidth() * 100), 100) + "%")
};
e(),
t(window).resize(e)
}
this.opts.arrows && this.el.parent().append('<p class="arrows"><span class="prev">â†</span><span class="next">→</span></p>').find(".arrows span").click(function () {
t.isFunction(i[this.className]) && i[this.className]()
}),
t.event.swipe && this.el.on("swipeleft", i.prev).on("swiperight", i.next)
},
this.move = function (s, e) {
this.items.eq(s).length || (s = 0),
0 > s && (s = this.items.length - 1);
var n = this.items.eq(s),
h = {
height : n.outerHeight()
},
o = e ? 5 : this.opts.speed;
this.ul.is(":animated") || (i.el.find(".dot:eq(" + s + ")").addClass("active").siblings().removeClass("active"), this.el.animate(h, o) && this.ul.animate(t.extend({
left : "-" + s + "00%"
}, h), o, function () {
i.current = s,
t.isFunction(i.opts.complete) && !e && i.opts.complete(i.el)
}))
},
this.start = function () {
i.interval = setInterval(function () {
i.move(i.current + 1)
}, i.opts.delay)
},
this.stop = function () {
return i.interval = clearInterval(i.interval),
i
},
this.keys = function (s) {
var e = s.which,
n = {
37 : i.prev,
39 : i.next,
27 : i.stop
};
t.isFunction(n[e]) && n[e]()
},
this.next = function () {
return i.stop().move(i.current + 1)
},
this.prev = function () {
return i.stop().move(i.current - 1)
},
this.dots = function () {
var s = '<ol class="dots">';
t.each(this.items, function (t) {
s += '<li class="dot' + (1 > t ? " active" : "") + '">' + (t + 1) + "</li>"
}),
s += "</ol>",
this.el.addClass("has-dots").append(s).find(".dot").click(function () {
i.move(t(this).index())
})
}
};
t.fn.unslider = function (s) {
var e = this.length;
return this.each(function (n) {
var h = t(this),
o = (new i).init(h, s);
h.data("unslider" + (e > 1 ? "-" + (n + 1) : ""), o)
})
}
}
(window.jQuery, !1);
* {
margin: 0;
padding: 0;
}
#outermin1 {
width : 100%;
}
.banner {
position : relative;
width : auto !important;
overflow : auto;
text-align : center;
}
/*
*/
.banner ul {
list-style : none;
width : 300%;
padding: 0px;
}
.banner ul li {
display : block;
float : left;
width : 33%;
padding : 0 0 110px;
min-height: 1550px !important;
max-height: 1550px !important;
}
.banner h1 {
position : relative;
margin : 0 auto;
height : 120px;
top : 30px;
text-align : center;
font-size : 250% !important ;
color : #FFF;
text-transform : uppercase;
font-weight : 100;
/*line-height : 38px !important ;*/
}
.banner h2 {
text-transform : none;
font-size : 150%;
top : -15px;
position : relative;
color : #FFF;
}
.banner .btn {
display : inline-block;
margin : 25px 0 0;
padding : 9px 22px 7px;
clear : both;
color : #fff;
font-size : 12px;
font-weight : 700;
text-transform : uppercase;
text-decoration : none;
border : rgba(255, 255, 255, 0.4) solid 2px;
border-radius : 5px;
}
.banner .btn:hover {
background : rgba(255, 255, 255, 0.05);
}
.banner .dots {
position: absolute;
left: 0px;
right: 0px;
bottom: -10px;
background: #fff;
height: 103px;
padding-top: 30px;
}
.banner .dots li {
display : inline-block;
width : 10px;
height : 10px;
margin : 0 4px;
text-indent : -999em;
border : #17b7a5 solid 2px;
border-radius : 6px;
cursor : pointer;
opacity : 0.4000000059604644775390625;
transition : background 0.5s, opacity 0.5s;
}
.banner .dots li.active {
background : #17b7a5;
opacity : 1;
}
/*
.banner img {
width: 100%;
margin-top: -143px;
}*/
.banner img {
background-size: cover;
z-index: 3;
}
/* this is the tryout part */
.banner > li { position: relative; }
.banner > li > img { position: absolute; top: 0; width: 3940px !important; text-align: center;}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">
<title>theimapcter.org</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/banner.css" rel="stylesheet">
<link href="css/egyedi.css" rel="stylesheet"> <!-- a kialakitas -->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="js/unslider.min.js"></script>
<script type="text/javascript">
$(function() {
$('.banner').unslider({
speed: 500,
delay: 15000,
complete: function() {},
keys: true,
dots: true,
fluid: true
});
});
</script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="svg/impacter_logo_fejlec.svg" alt="logo"></a>
</div>
<div id="navbar" class="collapse navbar-collapse" >
<ul class="nav navbar-nav">
<li><a href="">Projects</a></li>
<li><a href="">Mindset</a></li>
<li><a href="">Make an impact</a></li>
<li><a href="">Search</a></li>
<li><a href="">Login / Register</a></li>
</ul>
</div>
</nav>
<div class="box" id="outermin1" style="z-index:4">
<!--banner-->
<div class="banner">
<ul>
<li style="background:#00b8a5;"><div class="slider-wrapper"><div class="slide-outer"><div class="slide-szoveg">
<h1 class="cim1">Do you have the ability to respond challenges?</h1><h2 class="cim2">In other words: how do you deal with responsibility?</h2><br/><div class="start-slide"><span class="start-slide1">Start</span><br/><span class="start-slide2">the responsibility quick TEST!</span></div><span class="join-slide">Join the social experiment</span>
<span class="use-slide">Use Impacter platform to develop new ways and solve actual social/environmental<br/>challenges responsibly – meanwhile learn about yourself.</span><span class="find-slide">Find your challenge</span></div></div><img src="https://dl.dropboxusercontent.com/s/8nop7364npk31ue/slide1.png" alt="lab" class="slide1" /></div>
</li>
<li style="background:#8fc453;"><div class="slider-wrapper"><div class="slide-outer"><div class="slide-szoveg">
<h1 class="cim3">Projects with real-life impact</h1><h2 class="cim3">Activate ideas to generate change </h2><br/><br/><span>Upload a challenge</span> <span>Join a project</span></div></div><img src="https://dl.dropboxusercontent.com/s/7l99ejj81bd2g1d/slide2.png" alt="World map" class="slide2" /></div>
</li>
<li style="background:#37c6ea;"><div class="slider-wrapper"><div class="slide-outer"><div class="slide-szoveg">
<h1>Develop new ways to solve actual social / environmental challenges</h1><br/><br/><h2><strong class="line2">– meanwhile learn about yourself.</strong></h2><span>Challenges</span><span>Taking<br/>the responsibility</span><span>Response</span><span>Make an impact</span></div></div><img src="https://dl.dropboxusercontent.com/s/geiezcd6hym6mxt/slide3.png" alt="people on pc" class="slide3" /></div></li>
</ul>
<div style="height:50px;"> </div>
</div>
</div>
<!-- Main jumbotron for a primary marketing message or call to action -->
<!--<div id="banner-alatt">-->
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
<hr>
<footer>
<p>© 2015 Company, Inc.</p>
</footer>
</div> <!-- /container -->
<!-- </div> -->
<!-- <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> -->
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
编辑 2016.07.23.:我忘了说,我只想将图像的 1920px 部分居中。
最佳答案
我更喜欢另一个技巧。我不知道您的特定 slider 是否可以为 div 设置动画,但您可以将图像作为背景图像提供给该 div。比使用 background-size: cover;
浏览器将始终为您选择合适的尺寸。
关于javascript - Unslider:即使在 "low"屏幕分辨率下也能居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38487003/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!