简体   繁体   English

轮播字幕向右移动并占据轮播的一半

[英]carousel-caption move right and take half of carousel

I need to make my bootstrap 3 carousel-caption take half of my carousel , to make caption background-color a little transparent, and write some text into it. 我需要让我的自举3 carousel-caption拿我一半的carousel ,使caption背景颜色有点透明,并写一些文字到它。

So the logic is that in carousel background I will have pictures and for every picture caption will take half of carousel whit custom text. 因此逻辑是,在carousel背景中,我将拥有图片,并且对于每个图片caption都将使用一半的carousel白描自定义文本。

See my JSFIDDLE example, and I want to make it like this. 参见我的JSFIDDLE示例,我想像这样。 在此处输入图片说明

So far I manage to set up background of carousel-caption , and I know how to pull it to the left, the problem is right side, it's just confusing how does float: right want work, further more there is a small padding-bottom so how can I remove this? 到目前为止,我已经成功设置了carousel-caption背景,并且我知道如何将其向左拖动,问题是在右侧,只是使float: right感到困惑float: right需要工作,此外还有一个小的padding-bottom所以我该如何删除呢? Can any one help me over come this and build it properly, thanks. 有人可以帮我解决这个问题并正确构建它吗,谢谢。

<!-- Carousel -->
<div id="homeCarousel" class="carousel slide">
    <!-- Menu -->
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>
    <!-- Items -->
    <div class="carousel-inner">
        <!-- Item 1 -->
        <div class="item active">
            <img src="http://lorempixel.com/1500/600/abstract/1" />
            <div class="container">
                <div class="carousel-caption">
                     <h1>Bootstrap 3 Carousel Layout</h1>

                    <p>This is an example layout with carousel that uses the Bootstrap 3 styles.</p>
                    <p><a class="btn btn-lg btn-primary" href="http://getbootstrap.com">Learn More</a>

                    </p>
                </div>
            </div>
        </div>
        <!-- Item 2 -->
        <div class="item">
            <img src="http://lorempixel.com/1500/600/abstract/2" />
            <div class="container">
                <div class="carousel-caption">
                     <h1>Changes to the Grid</h1>

                    <p>Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.</p>
                    <p><a class="btn btn-large btn-primary" href="#">Learn more</a>

                    </p>
                </div>
            </div>
        </div>
        <!-- Item 3 -->
        <div class="item">
            <img src="http://lorempixel.com/1500/600/abstract/3" />
            <div class="container">
                <div class="carousel-caption">
                     <h1>Percentage-based sizing</h1>

                    <p>With "mobile-first" there is now only one percentage-based grid.</p>
                    <p><a class="btn btn-large btn-primary" href="#">Browse gallery</a>

                    </p>
                </div>
            </div>
        </div>
    </div>
    <!-- Controls --> <a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="icon-prev"></span>
  </a>
 <a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="icon-next"></span>
  </a> 
</div>

Carousel CSS: 轮播CSS:

#carouselButtons {
    margin-left: 100px;
    position: absolute;
    bottom: 0px;
}
.carousel-caption {
    position: absolute;
    left: auto;
    right: auto;
    width: 50%;
    height: 100%;
    background-color: #428bca;
    opacity: 0.8
}

You were very close - I added a reference to jquery in your fiddle, but the alignment issues you were facing were resolved by using the bottom and right properties. 您非常接近-我在您的小提琴中添加了对jquery的引用,但是您通过使用bottom和right属性解决了您面临的对齐问题。 Float was not the way to go here, since you already had .carousel-caption positioned absolutely, I just added a right:0, and a bottom:0 to your class. Float并不是要走的路,因为您已经绝对定位了.carousel-caption,所以我只为您的课程添加了right:0和bottom:0。

.carousel-caption {
    position: absolute;
    left: auto;
    right: auto;
    width: 50%;
    height: 100%;
    background-color: #428bca;
    opacity: 0.8;
    bottom:0;
    right:0;
}

See the updated Fiddle here https://jsfiddle.net/jy989rkt/4/ 在这里查看更新的小提琴https://jsfiddle.net/jy989rkt/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM