【问题标题】:Bootstrap carousel arrow positioningBootstrap 轮播箭头定位
【发布时间】:2017-12-26 11:57:07
【问题描述】:

我在这件事上摸不着头脑。目前,我的箭头放在旋转木马的瓷砖外面。见下文:

如何向下移动箭头,使它们像下面一样在左右指示器的外侧旁边而不重叠?

此网络应用会根据用户登录的内容填充不同的磁贴,因此请务必根据每个用户填充的轮播指示器的数量来调整箭头。

HTML

<div id="{{ game_group }}-game-carousel" class="carousel slide">
<div class="test">
<div class="carousel-indicator-wrapper">

    <ol class="carousel-indicators">
        {% for obj in game_data %}
            <li data-target="#{{ game_group }}-game-carousel" data-slide-to="{{ forloop.counter0 }}" class="{% if forloop.counter == 1 %}active{% endif %}"></li>
            {% if game_group != "NS" and forloop.last %}
                <li data-target="#{{ game_group }}-game-carousel" data-slide-to="{{ forloop.counter0 | add:"1" }}"></li>
            {% endif %}
        {% endfor %}
    </ol>

</div>
<a class="carousel-control left" href="#{{ game_group }}-game-carousel" data-slide="prev"><i class="icon-chevron-left" aria-hidden="true"></i></a>
<a class="carousel-control right" href="#{{ game_group }}-game-carousel" data-slide="next"><i class="icon-chevron-right" aria-hidden="true"></i></a>
</div>
</div>

CSS

#SL-game-carousel, #CL-game-carousel{
height: 425px;
margin-bottom:0px;
border:0px solid red;
}

#NS-game-carousel{
height:180px;
margin-bottom:0px;
border:0px solid red;
}

.carousel-indicator-wrapper{
  position:absolute;
  top:160px;
  z-index: 5;
  width:100%;
}

#lobby-tab-content .carousel-indicator-wrapper{
  top: 362px;
}

.carousel-indicators {
  position:relative;
  padding:0;
  /*use this display this to center the indicators horizontally*/
  display:table;
  margin:0 auto;
  top: 0px;
}

.carousel-indicators li {
background-color: rgba(223, 223, 223, 0.40);
border-radius: 5px;
height: 10px;
margin-left: 2px;
margin-right: 2px;
width: 10px;
cursor: pointer;
}

.carousel-indicators .active {
  background: rgb(255,255,255);
}

.test {
text-align: center;
}

.slot-carousel {
  width:640px;
  height:345px;
  /*background-color:rgba(255,0,0,.3);*/
  margin: 0 auto;
}

#NS-game-carousel .slot-carousel {
height:180px;
}

#lobby-tab-content #SL-game-carousel .carousel-control, #NS-game-carousel                 
.carousel-control, #CL-game-carousel .carousel-control {
  margin: /*178px 0px 0px 270px*/; 
  border-radius: 0;
  background-color:transparent;
  color: #dfdfdf;
  font-size: 38px;
  height: 40px;
  width: 40px;
  opacity: 1;
  filter: alpha(enabled='false');
  border:0;
  text-decoration: none;
}

#lobby-tab-content #SL-game-carousel .carousel-control.right, #NS-game-carousel .carousel-control.right, #CL-game-carousel .carousel-control.right {
  margin: /*178px 299px 0px 0px*/;
}

.icon-chevron-left:hover {
    color: #d8d8d8 /*#cbcbcb*/;
}
.icon-chevron-right:hover {
    color: #d8d8d8 /*#cbcbcb*/;
}

#game-lobby #NS-game-carousel .carousel-control{
  margin-top:-27px;
}

#game-lobby #NS-game-carousel .carousel-control.right{
  margin-top:-24px;
}

.carousel-control.left {
    background-image: none !important;/*url('/static/images/arrow-left.png');*/
    background-position: 0px 0px;
    background-repeat: no-repeat;
}

.carousel-control.right {
    left: auto;
    right: 15px;
    background-image: none !important; /*url('/static/images/arrow-right.png')*/
    background-position:0px 0px;
    background-repeat:no-repeat;
}

非常感谢任何帮助。谢谢!

【问题讨论】:

    标签: jquery html css twitter-bootstrap


    【解决方案1】:

    尝试为轮播箭头的类添加边距,如下所示 -

    .carousel-control.left {
        margin-right: 15px;
    }
    .carousel-control.right {
        margin-left: 15px;
    }
    

    【讨论】:

      【解决方案2】:

      尝试将 top:90% 添加/更新到您的 CSS 以降低它们

          .carousel-control .glyphicon-chevron-left, .carousel-control .glyphicon-chevron-right, .carousel-control .icon-next, .carousel-control .icon-prev {
          position: absolute;
          top: 90%;
      }
      

      然后减小/增加.carousel-control

      的宽度
      .carousel-control {
          width: 66%;
      }
      

      希望对你有帮助

      【讨论】:

      • 你的第一个代码块没有出现在检查元素中:/
      • 不走运,我的朋友...箭头现在位于图块的中间,甚至没有靠近指示器
      • 可以分享网址吗?
      • 我的朋友不行,它在本地主机上。我可以通过 Dropbox 链接向您发送快照吗?
      • 如果您的 localhost 在 Laragon 上,您可以使用 ngrok 创建一个可共享的 url。拉拉贡就像沼泽。您可以快速安装它,将您的项目复制到那里,右键单击该图标,您将看到 Ngrok,并分享您的 url。 cmd 将有一个类似8ab123.ngrok.io 的网址
      【解决方案3】:

      这会将箭头放在同一行, 引导版本 4.4

          <div class="col-md-8 h-100">
            <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
              <ol class="carousel-indicators">
                <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="1" class=""></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="2" class=""></li>
                <a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-slide="prev">
                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
                </a>
                <a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-slide="next">
                  <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
                </a>
              </ol>
              <div class="carousel-inner">
                <div class="carousel-item active">
                  <img class="d-block w-100 img-carousel" alt="First slide [800x400]"
                    src="{{ static_url('assets/img/1.svg')}}" data-holder-rendered="true">
                  <div class="carousel-caption d-none d-md-block text-dark">
                    <h5>What is lol?</h5>
                    <p>
                      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                      Nulla vitae elit libero, a pharetra augue mollis interdum.
                    </p>
                  </div>
                </div>
                <div class="carousel-item">
                  <img class="d-block w-100 img-carousel" alt="Second slide [800x400]"
                    src="{{ static_url('assets/img/2.svg')}}">
                  <div class="carousel-caption d-none d-md-block text-dark">
                    <h5>Second slide label</h5>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                  </div>
                </div>
                <div class="carousel-item">
                  <img class="d-block w-100 img-carousel" alt="Third slide [800x400]" data-holder-rendered="true"
                    src="{{ static_url('assets/img/3.svg')}}">
                  <div class="carousel-caption d-none d-md-block text-dark">
                    <h5>Third slide label</h5>
                    <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
                  </div>
                </div>
              </div>
              <!-- <a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
              </a>
              <a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
              </a> -->
            </div>
          </div>
      

      【讨论】:

        【解决方案4】:

        试试这个:

        .carousel-control {
            width: 30%;/*put your desired width*/
            margin-top: 150px;/*put your desired top margin*/
        }
        

        【讨论】:

          猜你喜欢
          • 2014-11-06
          • 2019-07-12
          • 2017-11-06
          • 2018-05-01
          • 1970-01-01
          • 2018-11-30
          • 1970-01-01
          • 1970-01-01
          • 2018-04-07
          相关资源
          最近更新 更多