编辑引导幻灯片

时间:2017-07-20 11:18:47

标签: css twitter-bootstrap less

我想让我的bootstrap幻灯片显示如下:

enter image description here

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

2 个答案:

答案 0 :(得分:0)

你应该使用Bootstrap carousal。请参阅以下链接 https://www.w3schools.com/bootstrap/bootstrap_carousel.asp

答案 1 :(得分:0)

好的,我找到了答案。只需将bootstrap source 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/