Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

html - border radius of a div inside another div is overlapping

I am making this card using React, HTML and CSS

enter image description here

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:

enter image description here

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?

question from:https://stackoverflow.com/questions/65868700/border-radius-of-a-div-inside-another-div-is-overlapping

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...