Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounding Bootstrap 3 Carousel Corners

I am trying to style a Bootstrap 3 carousel with CSS to have rounded corners. I am able to round the corners of the images in the carousel, but for some reason the background carousel edges remain unrounded. What am I doing wrong here?enter image description here

<style type="text/css">
.carousel {
    border-radius: 55px 55px 55px 55px;
    height: 500px;
    margin-bottom: 60px;
    margin-top: 40px;
    margin-left: 200px;
    margin-right: 200px;
}
/* Since positioning the image, we need to help out the caption */
 .carousel-caption {
    z-index: 10;
}
/* Declare heights because of positioning of img element */
 .carousel .item {
    width: 100%;
    height: 500px;
    background-color: #777;
}
.carousel-inner > .item > img {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 100%;
    height: 500px;
}
@media (min-width: 768px) {
    .carousel-caption p {
        margin-bottom: 20px;
        font-size: 21px;
        line-height: 1.4;
    }
}
img {
    border-radius: 55px 55px 55px 55px;
}
</style>

<div id="carousel" class="carousel slide" data-ride="carousel" data-interval="30000" data-pause="hover">
    <!-- Menu -->
    <ol class="carousel-indicators">
        <li data-target="#carousel" data-slide-to="0" class="active"></li>
        <li data-target="#carousel" data-slide-to="1"></li>
        <li data-target="#carousel" data-slide-to="2"></li>
    </ol>

    <!-- Items -->
    <div class="carousel-inner">

        <div class="item active">
            <img src="images/image3.jpg" alt="Slide 1" />
        </div>
        <div class="item">
            <img src="images/image7.jpg" alt="Slide 2" />
        </div>
        <div class="item">
            <img src="images/image6.jpg" alt="Slide 3" />
        </div>
    </div> 
    <a href="#carousel" class="left carousel-control" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a href="#carousel" class="right carousel-control" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
</div>
like image 488
Fetus Avatar asked Aug 21 '14 14:08

Fetus


3 Answers

None of the above worked for me as the slides only got rounded after sliding, but still showed square edges on sliding. For me the following worked like a charm.

.carousel-inner {
    border-radius: 25px;
    background-color: rgba(0,0,0,0);
    overflow: hidden;
}
like image 185
Chris Avatar answered Nov 07 '22 17:11

Chris


You need to hide the overflow:

.carousel {
    border-radius: 55px 55px 55px 55px;
    overflow: hidden;
    ...
}
like image 15
James Donnelly Avatar answered Nov 07 '22 16:11

James Donnelly


/* Declare heights because of positioning of img element */
 .carousel .item {
    width: 100%;
    height: 500px;
    background-color: #777;
    border-radius: 55px 55px 55px 55px;
}

Add this and it should work.

like image 1
Webice Avatar answered Nov 07 '22 17:11

Webice