steerr
steerr

Reputation: 150

How to get rid of the ribbon border by CSS?

I am trying to create a ribbon around a div using Bootstrap 4.

I can't clean the right border; on mobile, when the page is shrinked, my ribbon overflows to the right, out of parent div: https://jsfiddle.net/auj4q3a2/

Html:

<div class="container-fluid">

    <div class="card profile-card">  
        <div class="container-fluid">
            <div class="row user-social-detail">
                <div class="col-lg-12 col-sm-12 col-12">
                    <a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a>
                    <a href="#"><i class="fa fa-twitter" aria-hidden="true"></i></a>
                    <a href="#"><i class="fa fa-instagram" aria-hidden="true"></i></a>
                    <a href="#"><i class="fa fa-linkedin" aria-hidden="true"></i></a>
                </div>
            </div>
        </div>
    </div>

</div>

CSS:

.profile-card {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    max-width: 475px;
    margin: auto;
    text-align: center;
}

.user-social-detail{
    margin: 0 -30px;
    padding: 15px 0px;
    background-color: #ffd280;
    border-radius: 4px;
}
.user-social-detail a i{
    color:#fff;
    font-size:23px;
    padding: 0px 5px;
}
.user-social-detail::before,
.user-social-detail::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: -45px;
  top: -28px;
  display: block;
  width: 40px;
  height: 0px;
  border: 30px solid transparent;
  border-right: 20px solid #e5bd73;
  border-bottom-color: transparent;
  border-left-color: transparent;
}

.user-social-detail::after {
  left: auto;
  right: -45px;
  border-left: 20px solid #e5bd73;
  border-right: 30px solid transparent;
}

How can I fit the ribbon into the container on mobile, as on the left side?

Any suggestion or feedback will be welcomed and greatly appreciated.

Upvotes: 0

Views: 368

Answers (1)

Got it!

You have to add

overflow-x: hidden !important; to .container-fluid

EDIT: Actually, only in 1st .container-fluid this is necessary, so you can add the following to your CSS file:

.container-fluid:first-of-type {
    overflow-x: hidden !important;
}

Upvotes: 1

Related Questions