CSS - Border Radius and Solid Border Curved Inside

CSS - border radius and solid border curved inside

you can use border-radius values as twice the border-size value to obtain inside-rounded corners.

-webkit-border-radius: 16px;
-moz-border-radius: 16px;
border-radius: 16px;

border:white solid 8px;

How to make round corners to both inside of a box and its border?

Inner border calculations

First, you'll need to remove -vendor-background-clip: padding-box or set them to border-box the default in order to achieve the inner border radius.

The inner border radius is calculated as the difference of the outer border radius (border-radius) and the border width (border-width) such that

inner border radius = outer border radius - border width

Whenever the border-width is greater than the border-radius, the inner border radius is negative and you get some awkward inverted corners. Currently, I don't believe there is a property for adjusting the inner-border-radius, so you'll need to calculate it manually.

In your case:

inner border radius = 6px - 5px = 1px

Your new CSS should be:

.radius-all { border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px; }
.template-bg { background: #FFF; }
.template-border { border: 5px solid rgba(255, 255, 255, 0.2); }

Simply subtract the border-radius (6px) values from the border-width value (5px) in order to achieve your desired inner-border-radius:


Code that works for me

Tested on Firefox 3.x, Google Chrome, and Safari 5.0

 .radius-all { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; }
.template-bg { background: #FFF; }
.template-border { border: 5px solid rgba(0, 0, 0, 0.2); } /* Note that white on white does not distinguish a border */

Adding color overlays in JavaScript

<script type="text/javascript">
var bodyBgColor = document.getElementsByTagName('body')[0].style.backgroundColor;;

// insert opacity decreasing code here for hexadecimal

var header = document.getElementsByTagName('header')[0];
header.style.backgroundColor = bodyBgColor;
</script>

I'm not entirely sure how to do hexadecimal arithmetic in JavaScript but I'm sure you can find an algorithm in Google.


Applying General Borders

Are you using a separate box <div> for your border through its background property? If so, you'll need to apply border-radius and its vendor specific properties on both the border box and the inner box:

<div id="border-box" style="border-radius: 5px;">
<div id="inner-box" style="border-radius: 5px;">
</div>
</div>

A much more efficient way would simply have the inner-box manage its own border:

<div id="inner-box" style="border: 4px solid blue; border-radius: 5px">
<!-- Content -->
</div>

CSS-wise, you could just declare a .rounded-border class and apply it to every box that will have rounded borders:

.rounded-borders {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
}

And apply the class to any boxes that will have rounded borders:

<div id="border-box" class="rounded-borders">
<div id="inner-box" class="rounded-borders">
</div>
</div>

For a single box element, you'll still be required to declare the border size in order to be shown:

<style type="text/css">
#inner-box { border: 4px solid blue; }
</style>

<div id="inner-box" class="rounded-borders">
</div>

How do I achieve a thick border with inner border radius only

the simple way: you can have 2 dives 

<div class="a">
<div class="b">
</div>
</div>

.b{
display: block;
width: 50px;
height: 50px;
background-color: yellow;
border-radius: 5px;
}
.a{
border: 15px solid;
width: auto;
height: auto;
display: inline-block;
background-color: black;
}

Element with border-radius inside element with border-radius is not consistent

You can use inset box-shadow instead of border.

.parent {
/*border: 3px solid tomato;*/
background-color: white;
height: 200px;
border-radius: 30px;
box-shadow: inset 0px 0px 0 3px tomato;
}

.child {
border: 3px solid tomato;
padding: 10px;
border-bottom: none;
background-color: tomato;
height: 100px;
border-radius: 30px 30px 0 0;
box-sizing: border-box;
}
<div class="parent">
<div class="child">
</div>
</div>

Rounded inside border-radius in css without nested divs

You can but it won't be usable I presume, since there is z-index: -1; once there is another background it will go behind it...

#s {
position: relative;
width:200px;
height: 200px;
border-radius:8px;
background-color: red;
margin:0 auto;
}
#s:before {
content:'';
z-index: -1;
background-color: green;
position: absolute;
top: -8px;
left: -8px;
width: 216px;
height: 216px;
}

Demo

rounded corner for bottom border using css

Here you go. You need to add a div and give it a border-bottom. I have changed the HTML and CSS below. You can increase the div's height and width as you like

.footer_line {
white-space: nowrap;
margin-top: 12px;
font-weight: bold;
padding-bottom: 1px;
font-size: 36px;
width: 150px;
border-radius: 4px !important;
}

.news_let {
margin-left: 0px !important;
font-weight: bold !important;
letter-spacing: 1px !important;
color: white !important;
font-size: 21px !important;
border-bottom: 4px solid #2782dd !important;
border-radius:4px;
}
<div class="col-md-6">
<h3 class="footer_line">News Letter
<div class="news_let"></div>
</h3><br/>
</div>

More rounded corner - Border Radius CSS

You would need to elongate your border-radius:

.test {  border: 1px solid black;  text-align:center;    /* border-top-left-radius: horizontal vertical */  border-top-left-radius: 50px 20px;}
<div class="test">  lorem ipsum</div>


Related Topics



Leave a reply



Submit