【问题标题】:Edit bootstrap slideshow编辑引导幻灯片
【发布时间】:2017-12-26 01:28:17
【问题描述】:

我想让我的引导幻灯片看起来像这样:

有谁知道我如何做到这一点?所以我想要边缘的导航,带有背景颜色的白色图标和居中的文本。如果可能的话,有人可以告诉我如何编辑引导较少的源来做到这一点。

【问题讨论】:

  • 代码?你想让我们为你做吗?
  • 使用开发者工具 (F12) 并找到您想要定位的元素,并使用新的 css 文件覆盖样式。
  • 我制作了这个简短(笨拙)的视频,向您展示我将如何做到这一点。不是很优雅,但它可以解决问题。 dropbox.com/s/7qvyhodkbcgd8qf/custom-bs.mp4?dl=0

标签: css twitter-bootstrap less


【解决方案1】:

好的,我找到了答案。只需将引导源 carousel.less 文件编辑为:

carousel.less

    //
// Carousel
// --------------------------------------------------


// Wrapper for the slide container and indicators
.carousel {
position: relative;
}

.carousel-inner {
position: relative;
overflow: hidden;
width: 100%;
margin-bottom: 50px;

> .item {
display: none;
position: relative;
.transition(.6s ease-in-out left);

// Account for jankitude on images
> img,
> a > img {
  &:extend(.img-responsive);
  line-height: 1;
}

// WebKit CSS3 transforms for supported devices
@media all and (transform-3d), (-webkit-transform-3d) {
  .transition-transform(~'0.6s ease-in-out');
  .backface-visibility(~'hidden');
  .perspective(1000px);

  &.next,
  &.active.right {
    .translate3d(100%, 0, 0);
    left: 0;
  }
  &.prev,
  &.active.left {
    .translate3d(-100%, 0, 0);
    left: 0;
  }
  &.next.left,
  &.prev.right,
  &.active {
    .translate3d(0, 0, 0);
    left: 0;
  }
}
}

> .active,
> .next,
> .prev {
display: block;

}

> .active {
left: 0;
}

> .next,
> .prev {
position: absolute;
top: 0;
width: 100%;
}

> .next {
left: 100%;
}
> .prev {
left: -100%;
}
> .next.left,
> .prev.right {
left: 0;
}

> .active.left {
left: -100%;
}
> .active.right {
left: 100%;
}

}

// Left/right controls for nav
// ---------------------------

.carousel-control {
position: absolute;
top: 50%;
font-size: @carousel-control-font-size;
color: #fff;
text-align: center;
text-shadow: @carousel-text-shadow;
background-color: rgba(0, 0, 0, 0); // Fix IE9 click-thru bug
// We can't have this transition here because WebKit cancels the carousel
// animation if you trip this while in the middle of another animation.

// Set gradients for backgrounds

&.left {
//#gradient > .horizontal(@start-color: rgba(0,0,0,.5); @end-color: rgba(0,0,0,.0001));
margin-left: 10px;

}
&.right {
left: auto;
right: 0;
margin-right: 10px;

//#gradient > .horizontal(@start-color: rgba(0,0,0,.0001); @end-color: rgba(0,0,0,.5));
}

// Hover/focus state
&:hover,
&:focus {
outline: 0;
color: #eee;
text-decoration: none;
.opacity(.9);
}

// Toggles
.icon-prev,
.icon-next,
.glyphicon-chevron-left,
.glyphicon-chevron-right {
position: absolute;
top: 50%;
margin-top: -10px;
z-index: 5;
display: inline-block;
background-color: @carousel-control-color;


}
.icon-prev,
.glyphicon-chevron-left {
left: 50%;
margin-left: -10px;

}
.icon-next,
.glyphicon-chevron-right {
right: 50%;
margin-right: -10px;
}
.icon-prev,
.icon-next {
width:  20px;
height: 20px;
line-height: 1;
font-family: serif;
}


.icon-prev {
&:before {
  content: '\2039';// SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039)
}
}
.icon-next {
&:before {
  content: '\203a';// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A)
}
}
}

// Optional indicator pips
//
// Add an unordered list with the following class and add a list item for each
// slide your carousel holds.

.carousel-indicators {
position: absolute;
bottom: 10px;
left: 50%;
z-index: 15;
width: 60%;
margin-left: -30%;
padding-left: 0;
list-style: none;
text-align: center;

li {
display: inline-block;
width:  70px;
height: 5px;
text-indent: -999px;
cursor: pointer;
background-color:  #b0b8b9;
margin: 0 3px;

}
.active {
background-color: @carousel-indicator-active-bg;
}
}

// Optional captions
// -----------------------------
// Hidden by default for smaller viewports
.carousel-caption {
position: absolute;
left: 0;
right: 0;
top: 35%;
//background-color: rgba(51, 51, 51, 0.4);
z-index: 10;
padding: 10px 20px;
color: @carousel-caption-color;
text-align: center;
text-shadow: @carousel-text-shadow;
& .btn {
text-shadow: none; // No shadow for button elements in carousel-caption
}
}


// Scale up controls for tablets and up
@media screen and (min-width: @screen-sm-min) {

// Scale up the controls a smidge
.carousel-control {
.glyphicon-chevron-left,
.glyphicon-chevron-right,
.icon-prev,
.icon-next {
  font-size: 20px;
  padding: 20px 10px;
}
.glyphicon-chevron-left,
.icon-prev {
  margin-left: (@carousel-control-font-size / -2);
  border-radius: 0 5px 5px 0;

}
.glyphicon-chevron-right,
.icon-next {
  margin-right: (@carousel-control-font-size / -2);
  border-radius: 5px 0 0 5px;
}
}

// Show and left align the captions
.carousel-caption {
left: 20%;
right: 20%;
//width: 100%;
padding-bottom: 30px;
}

// Move up the indicators
.carousel-indicators {
bottom: -50px;
}
}

并在 variables.less 中设置您的主题颜色。使用 Koala 之类的程序重新编译为 bootstrap.css。 http://koala-app.com/

【讨论】:

    【解决方案2】:

    您应该使用 Bootstrap 轮播。参考下面的链接 https://www.w3schools.com/bootstrap/bootstrap_carousel.asp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多