Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make inverted rounded corners and "bend" content to follow curved container

Tags:

css

The carousel is designed with a rounded bottom, and the captions should follow that... I'm lost on how to achieve this.

The curved bottom comes from this code on my carousel:

.round-carousel {
    height: 600px;
    border-bottom-left-radius: 80% 20%;
    border-bottom-right-radius: 80% 20%;
    overflow-y: hidden;
    width: 105%;
    left: -3%;
}

wanted results

The thing I have so far... I'm lost on how to make the div curved. Maybe it's late at night and my brain is not functioning..

.carousel-indicators {
    height: 80px;
    background: rgba(0,0,0,0.5);
    width: 100%;
    margin: auto;
}

.carousel-indicators li {
    font-size: 0.9rem;
    height: 40px;
    text-indent: inherit;
    background: none;
    display: flex;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    -webkit-justify-content: flex-end;
    -moz-justify-content: flex-end;
    -ms-flex-pack: end;
    width: 12%;
    line-height: 1.3rem;
    position: relative;
    margin: 0 15px;
    flex-direction: column;
    -webkit-flex-direction: column;
-ms-flex-direction: column;
-moz-flex-direction: column;
    text-align: center;
}

.carousel-indicators li:after{
    height: 8px;
    width: 8px;
    border-radius: 100%;
    content: " ";
    background: #fff;
    position: absolute;
    left: 50%;
    bottom: -20px;
}

.carousel-indicators li.active{
color: #72c267;
}

.carousel-indicators li.active:after{
height: 10px;
width: 10px;
background: #72c267;
box-shadow: 0 0 0 2px #72c267;
border: 2px solid rgba(0, 0, 0, 0.6);
}

how to bend???

EDIT: Adding HTML Using bootstrap on wordpress, so this has some variables on php as well:

<section id="slider">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12 px-0">
                <div id="carouselExampleSlidesOnly" class="carousel slide main-image-slider" data-ride="carousel" data-interval="5000">
                    <div class="carousel-inner round-carousel">
                        <ol class="carousel-indicators align-items-center">
                            <?php  $number = 0;
        foreach(Home::getRepeatable(get_the_ID(),'carrousel_slide') ?? [] as $key =>
                            $value): ?>
                            <li class="<?= $key === 0 ? 'active' : '' ?>" data-target="#carouselExampleSlidesOnly" data-slide-to="<?php echo $number++; ?>"><?php echo $value['ss_slide_title'];?></li>
                            <?php endforeach; ?>
                        </ol>
                        <div class="carousel-overlay h-100 w-100"></div>
                        <?php foreach(Home::getRepeatable(get_the_ID(),'carrousel_slide') ?? [] as $key =>
                        $value):?>
                        <div class="carousel-item <?= $key === 0 ? 'active' : '' ?>">
                            <div class="carousel-caption">
                                <p><?php echo $value['ss_slide_desc']; ?></p>
                                <a class="btn btn-primary btn-md" href="<?=  $value['ss_slide_link']; ?>"><?php echo $value['ss_slide_button_text']; ?> </a>
                            </div>
                            <img class="img-fluid d-block w-100" src="<?= wp_get_attachment_url($value['ss_slide_image']); ?>" alt="First slide" />
                        </div>
                        <?php endforeach ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
like image 700
artist learning to code Avatar asked May 26 '21 01:05

artist learning to code


1 Answers

You should post also complete code, it is not always enough with CSS. (Enlico already commented this to you).

Anyway, a posible solution would be this, moving the elements in a vertical amount to make them rotate:

.container {
    width: 100%;
    position: relative;
    top: 200px;
}

.element {
    position: absolute;
    background-color: tomato;
    left: 50%;
    transform: translateY(-400px) rotate(var(--angle)) translateY(400px) rotate(calc(-1 * var(--angle)));
}

.element:nth-child(1) {
    --angle: 50deg;
}

.element:nth-child(2) {
    --angle: 30deg;
}

.element:nth-child(3) {
    --angle: 10deg;
}

.element:nth-child(4) {
    --angle: -10deg;
}

.element:nth-child(5) {
    --angle: -30deg;
}

.element:nth-child(6) {
    --angle: -50deg;
}
<div class="container">
    <div class="element">item 1</div>
    <div class="element">item 2</div>
    <div class="element">item 3</div>
    <div class="element">item 4</div>
    <div class="element">item 5</div>
    <div class="element">item 6</div>
</div>
like image 77
vals Avatar answered Sep 21 '22 10:09

vals