【问题标题】:Change height of Bootstrap slider更改 Bootstrap 滑块的高度
【发布时间】:2017-02-07 14:05:44
【问题描述】:

我已经尝试过更改 css,我可以通过在它周围创建一个 div 来更改它的宽度,例如,给它一个 80% 的宽度。但我不能那样改变高度。有人知道如何改变高度吗?请参阅下面的链接。

附言。无法在 sn-p 或没有空格键的情况下复制链接。抱歉。

代码笔:http://codepen.io/SitePoint/pen/ZbGwqe/

Js:

var $item = $('.carousel .item'); 
var $wHeight = $(window).height();
$item.eq(0).addClass('active');
$item.height($wHeight); 
$item.addClass('full-screen');

$('.carousel img').each(function() {
  var $src = $(this).attr('src');
  var $color = $(this).attr('data-color');
  $(this).parent().css({
    'background-image' : 'url(' + $src + ')',
    'background-color' : $color
  });
  $(this).remove();
});

$(window).on('resize', function (){
  $wHeight = 200;
  $item.height($wHeight);
});

$('.carousel').carousel({
  interval: 6000,
  pause: "false"
});

【问题讨论】:

  • 你不能因为你使用背景图片而不是图片标签。

标签: javascript jquery twitter-bootstrap twitter-bootstrap-3 slider


【解决方案1】:

它是用javascript编码的,所以

改变

var $wHeight = $(window).height();
$(window).on('resize', function (){
  $wHeight = $(window).height();
  $item.height($wHeight);
});

var $wHeight = 200; // >------- your wanted height
$(window).on('resize', function (){
  $wHeight = 200;   // >------- your wanted height
  $item.height($wHeight);
});

代码笔:http://codepen.io/anon/pen/mRGeoR

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 1970-01-01
    相关资源
    最近更新 更多