小编tru*_*lev的帖子

为风景和肖像设置不同的初始比例

我想在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不正确.有什么方法可以使它工作吗?

css ipad ios

13
推荐指数
1
解决办法
780
查看次数

在光滑的轮播中为视频添加自动播放

我在我的页面上使用光滑的轮播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我使用这个代码,它的工作原理 …

html javascript slick.js

13
推荐指数
1
解决办法
8912
查看次数

将"长影"SASS mixin转换为Less

我尝试重写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)

css sass css3 less

4
推荐指数
1
解决办法
810
查看次数

滚动一次调用函数

我有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)

javascript jquery

0
推荐指数
1
解决办法
1991
查看次数

输入文本在占位符中添加带有其他颜色的星号

如何在占位符中添加其他颜色的星星<input type="text" />带有格式的占位符

css jquery

0
推荐指数
1
解决办法
2380
查看次数

标签 统计

css ×3

javascript ×2

jquery ×2

css3 ×1

html ×1

ios ×1

ipad ×1

less ×1

sass ×1

slick.js ×1