Search code examples
htmlcssreactjsbootstrap-4border-radius

border radius of a div inside another div is overlapping


I am making this card using React, HTML and CSS

Here is my Code:

<div className="plan">
  <div className="plan-name">
    <h5>BASIC</h5>
  </div>
  <div className="plan-price">
    <h2>$ 6.99</h2>
    <span>Screen Availabilty Simultaneously</span>
  </div>
  <div className="plan-details">
    <ul>
      <li>
        <span>
          <CheckIcon />
        </span>
        Access to All Library in Unlimited
      </li>
      <li>New Content Monthly</li>
      <li>Available on PC, Smartphones and tablet</li>
      <li>Drawing in Color</li>
      <li>Color in Very High Quality</li>
      <li>Canceable at Any Time</li>
    </ul>
  </div>
</div>

CSS:

.plan {
    border-radius: 25px;
    overflow: hidden;
    background-color: #fff;
}

.plan-name {
    background-color: #3e104f;
    padding: 25px 0;
    border-style: solid;
    border-width: 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.plan-price {
    color: #3e104f;
    background-color: #fff;
    padding: 35px 0;
}

.plan-details {
    background-color: #3e104f;
    height: 100%;
    border-radius: 20px;
}

Output:

But I am getting the white border which I have highlighted above, on all corners. Can anyone tell me where am I doing wrong? Or from where it is coming? How do I hide it?


Solution

  • It's normal behavior, you have no mistake in your CSS.

    Possible solution is to make something like this

    .plan {margin-top: 25px; overflow: visible;} /* here just remove overflow: hidden to show .plan-name outside of .plan */
    .plan-name {margin-top: -25px; border-top-right-radius: 25px; border-top-left-radius: 25px;}
    

    Using this code .plan's radius is hidden underneath .plan-name and isn't visible in corners.