我想在Ipad上为风景和肖像设置不同的初始比例
我加入了 head
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
我试图使用这个脚本
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
function onOrientationChange()
{
var viewportmeta = document.querySelector('meta[name="viewport"]');
switch(window.orientation)
{
case -90:
case 90:
viewportmeta.content = 'initial-scale=0.6';
break;
default:
viewportmeta.content = 'initial-scale=0.8';
break;
}
}
window.addEventListener('orientationchange', onOrientationChange);
onOrientationChange();
Run Code Online (Sandbox Code Playgroud)
但是id不正确.有什么方法可以使它工作吗?
我在我的页面上使用光滑的轮播http://kenwheeler.github.io/slick/,现在我需要在其中添加带自动播放的视频.
我使用这段代码
HTML
<div class="main-slider" id="main-slider">
<div>
<div class="video-wrapper">
<video autoplay loop class="pageBackground-video">
<source src="/Content/video/332145276.mp4" type="video/mp4">
</video>
</div>
</div>
<div>
<div class="video-wrapper">
<video autoplay loop class="pageBackground-video">
<source src="/Content/video/332145276.mp4" type="video/mp4">
</video>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和脚本
$('#main-slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 30000,
dots: true,
infinite: true,
adaptiveHeight: true,
arrows: false
});
Run Code Online (Sandbox Code Playgroud)
但是自动播放不起作用.有没有办法让自动播放工作?
我尝试使用upd
$('#main-slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
var video = currentSlide.children('video').get(0).play();
});
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,Uncaught TypeError: currentSlide.children is not a function因为currentSlide它只是一个数字(0,1等).如何获得当前元素?
upd2我使用这个代码,它的工作原理 …
我尝试重写sass mixin用于生成长文本阴影
http://codepen.io/awesomephant/pen/mAxHz
到less mixin
.long-shadow(@type, @color, @length, @fadeout: true, @skew: false, @direction: right){
@shadow : '';
.if @skew == false or @type == text{
.if @direction == right {@
@for @i from 0 to @length - 1 {
@shadow: @shadow + @i + 'px ' + @i + 'px 0 ' + @color + ',';
}
}
.if @direction == left {@
@for @i from 0 to @length - 1 {
@shadow: @shadow + @i * -1 + 'px …Run Code Online (Sandbox Code Playgroud) 我有jQuery函数counter,我需要在滚动页面时调用它
$(document).ready(function () {
$.fn.counter = function () {
$(this).each(function () {
var num = $(this).data('counter');
var i = 1,
self = $(this).html(i);
var interval = setInterval(function () {
self.html(++i);
if (i >= num) {
clearInterval(interval);
}
}, 100);
});
};
$(window).scroll(function() {
var height = $(window).scrollTop();
if(height > 300) {
$('.counter-1, .counter-2, .counter-3, .counter-4').counter();
}
});
});
Run Code Online (Sandbox Code Playgroud)
问题是当我再次向上或向下滚动页面时,每次都会一次又一次地调用函数.
我试着使用这段代码
$(document).ready(function () {
$.fn.counter = function () {
$(this).each(function () {
var num = $(this).data('counter');
var i = …Run Code Online (Sandbox Code Playgroud)