Rounded Corners on Divs with Background Color

Rounded Corners on DIVs with Background Color

In your markup, you have to give border-radius to both #shell and #title so that the #title's sharp corners don't overlap #shell's.

A live example, http://jsfiddle.net/BXSJe/4/

#shell {
width: 500px;
height: 300px;
background: lightGrey;
border-radius: 6px;
}

#title {
background: green;
padding: 5px;
border-radius: 6px 6px 0 0;
}
<div id="shell">
<div id="title">TITLE HERE</div>
<div id="content">Article Content Goes Here</div>
</div>

Element with background inside DIV with rounded corners bleeding out

check this code, is this waht are you looking for ?

the overflow: hidden hides whatever passes the .outer_box borders

and padding: 10px; just to makes it look nice.

<!DOCTYPE html>
<html>
<head>
<title>Rounded Edges With Background</title>
<style>
body,
html {
width: 100%;
height: 100%;
}

.outer_box {
width: 500px;
background: #fff;
border: 2px solid #000;
border-radius: 25px;

overflow: hidden;
}

.title {
width: 100%;
background: #00f;
color: #fff;
margin-top:0;
background-clip: padding-box;

padding: 10px;
}
</style>
</head>
<body>
<div class="outer_box">
<h1 class="title">Here's a title</h1>
<p>Here's some content.</p>
</div>
</body>
</html>

border-radius + background-color == cropped border

Try overflow:hidden in the outer div:

<div style="border-radius:10px; border: 1px black solid; overflow: hidden">  <div style="background-color:#EEEEEE;">    Blah  </div></div>

How do I make a Div that has round corners and a background colour?

It seems you have 2 questions:
1. set background to an element; 2. you wanna set round corners to an element and works in safari.

  1. if you element is div tag, you need to set width,and height of your div tag, e.g:

    <div id='mydiv'>some elements here</div>

Your css:

   #mydiv { 
background-color: #111;
height: 100px;
width:100px
}

2. Setting round-corner(code below works for all browsers):

   .round-corner {
-webkit-border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-o-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
}

How to make rounded corners in css on different background

You can also achieve that using the :after pseudo element for the top section and bring that element back using z-index so it won't overlap the bottom section.

Here's an example:

.container {
width: 50%;
height: 200px;
display: flex;
margin: 0 auto;
overflow: hidden;
border-radius: 5px;
flex-direction: column;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.top-section {
flex-grow: 1;
background-color: #1B2149;
border-radius: 0 0 0 25px;
position: relative;
}

.top-section:after {
content: " ";
z-index: -1;
right: 0;
bottom: -30px;
height: 30px;
width: 40px;
position: absolute;
background-color: inherit;
}

.bottom-section {
flex-grow: 1;
border-radius: 0 25px 0 0;
background-color: #FFFFFF;
}
<div class="container">
<div class="top-section"></div>
<div class="bottom-section"></div>
</div>

Background color having rounded edges

You're looking for the rounded-0 utility class to remove the rounded corners..

   <div class="modal-header rounded-0">
<h4 class="modal-title"><b>Outage Details</b></h4>
</div>

Demo: https://www.codeply.com/go/XHvAXID48s

How to make div with round corner totally opaque inside, but colored outside (between round border line and original border-box line)?

You can consider a radial-gradient coloration for your element to achieve this.

Here is an example:

.wrapper {  padding:50px;  display:inline-block;  font-size:0;  background:url(https://picsum.photos/id/1069/1000/800) center/cover;}.wrapper > div {  width:150px;  height:150px;  display:inline-block;  background:    radial-gradient(farthest-side at bottom right,transparent 98%,yellow 100%) top left,    radial-gradient(farthest-side at bottom left ,transparent 98%,yellow 100%) top right,    radial-gradient(farthest-side at top    left ,transparent 98%,yellow 100%) bottom right,    radial-gradient(farthest-side at top    right,transparent 98%,yellow 100%) bottom left;  background-size:30px 30px;  background-repeat:no-repeat;}
<div class="wrapper">  <div></div>  <div></div>  <div></div>  <div></div>  <div></div>  <div></div></div>

How to prevent background color of an image to show through at rounded corners?

Bummer. You could transform: scale(1.05) as a way around it. Or put the image in the background of the parent. : /

I am not able to fill the round corners with color using css?

The blank space on the top of the .container is caused by the margin-top of the h4 element. You can replace it with a padding top and add an overflow:hidden on the #widget to prevent any content (here the square corners) to overflow.

Here is a working snippet.

#widget {    position: fixed;    width: 450px;    height:500px;    border-style: solid;    border-width: 1px;    box-shadow: 0 0 4px 0;    border-radius: 10px;        overflow:hidden;}
.container{ background-color: #0071B3; width:450px; height:250px;}
.header{ text-align: center;}
h4{ margin-top: 0; padding-top:1rem;}
<div id="widget">  <div class="container">    <div class="header">        <h4>Let's Enhance</h4>    </div>    <div class="info">     <div>   </div></div>

How to set the background colour for rounded corners with CSS?

you may also use a linear-gradient on the tr itself from transparent to dark for the last part:

<table>
<tr>
<td bgcolor="#2B2B34" width="60"></td>
<td bgcolor="#2B2B34" align="center" style="padding: 50px 0 50px 0;"></td>
<td bgcolor="#2B2B34" width="60"></td>
</tr>
<tr style="background:linear-gradient(0deg,transparent 80%, #2B2B34 80%)">
<td bgcolor="#2B2B34" width="60" height="80"></td>
<td rowspan="2" style="background: linear-gradient(122deg, #0014FF 0%, #BD2EFF 58%, #FF7828 100%) ; border-radius: 16px;">
<table align="center" cellpadding="0" cellspacing="0" width="480">
<tr>
<td align="center" style="padding: 40px 0 36px 0;"></td>
</tr>
<tr>
<td align="center" style="padding: 0 0 35px 0; font-family: 'JetBrains Mono'; font-size: 24px; letter-spacing: 0px; color: #FFFFFF;opacity: 1;">Hello</td>
</tr>
</table>
</td>
<td bgcolor="#2B2B34" width="60" height="80"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"></td>
<td bgcolor="#FFFFFF"></td>
</tr>
</table>


Related Topics



Leave a reply



Submit