CSS - Rounded concave corners for compound layout - html

First, I know there are similar questions available (like. Create concave corners in css) but they don't really cover this situation.
This is not about single cell/div element.
I have three blocks that will have some text content inside:
top-middle centered block (narrow)
middle-middle block (screen-wide)
bottom-middle centered block (narrow)
Basically something like a cross (text removed):
The outer corners (8) is straighforward but how could I achieve those inner ones (4)?

see bellow code, maybe it needs some adjustments but the idea is that you use pseudo-elements to make those inner borders
let me know if this is what you want
.colored {
background:yellow;
border:5px solid green;
width:100px;
height:100px;
box-sizing:border-box;
position:relative;
}
#content {
width:300px;
position:relative;
background:#000;
}
.top,.bottom { position:relative;margin:0 auto;clear:both}
.top { border-bottom:none}
.bottom { border-top:none}
.left { border-right:none}
.right { border-left:none;}
.colored.center { border:none;}
.left,.center,.right { float:left;}
.top { border-top-left-radius:10px;border-top-right-radius:10px;}
.bottom { border-bottom-left-radius:10px;border-bottom-right-radius:10px;}
.right { border-bottom-right-radius:10px;border-top-right-radius:10px;}
.left { border-bottom-left-radius:10px;border-top-left-radius:10px;}
.top:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
top:5px;
content:"";
border-bottom-right-radius:10px;
border-right:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.top:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
top:5px;
content:"";
border-bottom-left-radius:10px;
border-left:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
bottom:5px;
content:"";
border-top-right-radius:10px;
border-right:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
bottom:5px;
content:"";
border-top-left-radius:10px;
border-left:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
<div id="content">
<div class="top colored">
</div>
<div class="left colored">
</div>
<div class="center colored">
</div>
<div class="right colored">
</div>
<div class="bottom colored">
</div>
</div>

Variation with just three divs, a bit hacky but functional. Uses pseudo elements, transforms and inner box-shadow.
div {
background-color: #000;
min-height: 100px;
}
.center {
width: 100px;
margin: 0 auto;
}
.rounded {
border-radius: 20px;
border: 5px solid red;
}
.conc {
position: relative;
}
.conc::before,
.conc::after {
content: '';
position: absolute;
border: 5px solid red;
border-radius: 20px;
width: 25px;
height: 25px;
background-color: trnaspanret;
border-color: red transparent transparent;
z-index: 3;
box-shadow: white 0px 0px 0px 20px inset
}
.conc.bottom {
margin-bottom: -5px;
border-bottom: 0;
border-radius: 20px 20px 0 0
}
.conc.top {
margin-top: -5px;
border-top: 0;
border-radius: 0 0 20px 20px
}
.conc::before {
left: -35px;
}
.conc::after {
right: -35px;
}
.conc.top::before,
.conc.top::after {
top: 0px;
}
.conc.bottom::before,
.conc.bottom::after {
bottom: 0px;
}
.conc.bottom::before {
transform: rotate(135deg)
}
.conc.bottom::after {
transform: rotate(-135deg)
}
.conc.top::before {
transform: rotate(45deg)
}
.conc.top::after {
transform: rotate(-45deg)
}
.centerblinders {
position: relative;
}
.centerblinders::before,
.centerblinders::after {
content: '';
position: absolute;
width: 130px;
height: 20px;
background-color: #000;
left: 50%;
transform: translatex(-50%);
z-index: 2;
}
.centerblinders::before {
top: -15px;
}
.centerblinders::after {
bottom: -15px;
}
<div class="rounded center conc bottom"></div>
<div class="rounded centerblinders"></div>
<div class="rounded center conc top"></div>

Related

Adding border to webkit-mask-image

I have two containers and I want to link them with a negative-rounded-ish div : JSFIddle
HTML:
<div class="div"></div>
<div class="d-flex">
<div class="p1"></div>
<div class="p2"></div>
</div>
<div class="div"></div>
CSS:
.div {
background:#e0e0e0;
border:solid 1px red;
padding:10px;
border-radius:5px
}
.p1 {
background:#e0e0e0;
width: 25px;height: 10px;
-webkit-mask-image: radial-gradient(circle at left, transparent 0, transparent 19px, black 0px);
}
.d-flex { display:flex }
.p2 {
background:#e0e0e0;
width: 25px; height: 10px;
-webkit-mask-image: radial-gradient(circle at right, transparent 0, transparent 19px, black 0px);
}
Preview:
I want to know if I can extend borders to get sth like this
CSS tricks with before & after pseudo might help!
.div {
background:#e0e0e0;
border:solid 1px red;
padding:10px;
border-radius:5px
}
.join {
margin-left: 20px;
background:#e0e0e0;
width: 20px;
height: 10px;
overflow:hidden;
position:relative;
z-index:1;
margin-top:-1px;
margin-bottom: -1px;
}
.join:before, .join:after{
content: '';
height: 8px;
width: 10px;
position:absolute;
border-radius:10px;
border:1px solid red;
background-color:#fff;
}
.join:before{
left:-5px;
border-left: 0;
}
.join:after{
right:-5px;
border-right: 0;
}
<div class="div"></div>
<div class="join"></div>
<div class="div"></div>

How to make this css-border around this shape?

I Used to CSS-border-width to Make that shape but now I can't get a border around this shape. Or there is another option to make this shape.
Check Out On snippet
.month {
width: 0;
height: 0;
border: 61px solid transparent;
border-bottom-color: #008fc1;
position: relative;
top: -61px;
}
.month:after {
content: '';
position: absolute;
left: -61px;
top: 61px;
width: 0;
height: 0;
border: 61px solid transparent;
border-top-color: #acd3f1;
}
<div class="month">
</div>
You can simplify your code like below:
.month {
width:100px;
height:100px;
background:
linear-gradient(to bottom left,#008fc1 50%,#acd3f1 0) content-box,
#acd3f1;
padding:4px; /* to control the border */
margin:25px;
transform:rotate(-45deg);
}
<div class="month">
</div>
You can easily do this with a pseudo element to be able to add content:
.month {
width:100px;
height:100px;
position:relative;
z-index:0;
margin:25px;
color:#fff;
line-height:80px;
}
.month:before {
content:"";
position:absolute;
z-index:-1;
left:0;
right:0;
top:0;
bottom:0;
background:
linear-gradient(to bottom left,#008fc1 50%,#acd3f1 0) content-box,
#acd3f1;
padding:4px; /* to control the border */
transform:rotate(-45deg);
}
<div class="month">
some text here
</div>

Make a right outer curved layer for paragraph with CSS

I am trying to make a list of paragraphs, and one of them should be selected, just like the image below, but it seems I just cannot succeed.
I have tried something at: http://jsfiddle.net/bmj2j2wd/ but the end just just does not curve the way I would like it to... ie outwards, not inwards.
This is the css from there:
.active{
border:2px solid dodgerblue;
border-bottom:0;
width:80px;
height:32px;
margin:10px;
position:relative;
border-radius:16px 16px 0 0;
}
.active:after,
.active:before{
content:'';
width:80px;
height:32px;
border:2px solid dodgerblue;
position:absolute;
bottom:-8px;
border-top:0;
}
.active:after{
border-left:0;
border-radius:0 0 16px 0;
down:-16px;
}
.active:before{
border-right:0;
border-radius:0 0 0 16px;
up:-16px;
}
but it looks totally not right.
Very important would be that the two right lines after the curvature would go all the way up and down till the top and bottom of the page.
So, I'd like to ask for some help from the community in order to get this working.
You can basically use :before and :after to create a box on top and a box on bottom of your active <p> element (p.active). With these two boxes you can change the direction of the border. The following shows an example with a dynamic length based on the elements (Code on JSFiddle):
See the following solution (the original answer before edit):
.container :not(.active) {
border-right:1px solid dodgerblue;
margin:0;
padding:10px 10px 10px 20px;
width:72px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
height:32px;
line-height:32px;
margin:10px;
padding-left:10px;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:32px;
right:-2px;
position:absolute;
width:80px;
}
.active:after {
border-bottom-right-radius: 5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(100%);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
</div>
You want to set vertical border on the full height of the page. This is a very difficult thing but you can use the following solution using a container which hides the overflow (the too long borders) (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:100vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
}
.active:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
An additional, maybe useful, example using :hover instead of .active to set the active element. This is useful for tests too (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:80vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
border:1px solid transparent;
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
p:hover {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
p:hover:before, p:hover:after {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
z-index:-1;
}
p:hover:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
p:hover:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
You could use :after and :before pseudo elements and add border-radius.
.active {
padding: 15px;
margin: 60px;
border: 1px solid blue;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-right: 0;
display: inline-block;
border-right: none;
position: relative;
}
.active:before,
.active:after {
content: '';
position: absolute;
width: 30px;
height: 40px;
}
.active:before {
border-right: 1px solid blue;
border-bottom: 1px solid blue;
border-bottom-right-radius: 50%;
right: -30px;
top: 0;
transform: translateY(-100%);
}
.active:after {
border-right: 1px solid blue;
border-top: 1px solid blue;
border-top-right-radius: 50%;
right: -30px;
bottom: 0;
transform: translateY(100%);
}
<div class="active">Some selection</div>
Another option that uses span elements for the curved lines, instead of pseudoelements
fiddle
body {
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.active {
border: 1px solid red;
border-right: 0;
width: 80px;
height: 32px;
position: relative;
border-radius: 5px 0 0 5px;
display: flex;
align-items: center;
padding-left: 1em;
}
.curvy {
flex: 1;
width: 80px;
margin-left: 30px;
border: 1px solid red;
border-left: 0;
border-top: 0;
border-radius: 0 0 5px 0;
margin-bottom: -1px;
}
.active+.curvy {
margin-bottom: 0;
margin-top: -1px;
border-top: 1px solid red;
border-radius: 0 5px 0 0;
border-bottom: 0;
}
<span class="curvy"></span>
<div class="active">hi</div>
<span class="curvy"></span>
While the other two works but it was not all the way up & down.
To make the line longer/shorter, change the height & top value.
height: 50vh;
top: calc(-50vh - 1px);
.active{
border:1px solid red;
border-right:0;
width:80px;
height:32px;
margin: 150px auto 0;
position:relative;
border-radius: 10px 0px 0 10px;
padding: 10px;
}
.active:after,
.active:before {
content: '';
position: absolute;
width: 20px;
height: 50vh;
}
.active:before {
top: calc(-50vh - 1px);
right: -20px;
border-bottom-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-top: none;
}
.active:after{
bottom: calc(-50vh - 1px);
right: -20px;
border-top-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-bottom: none;
}
<div class="active">hi</div>

Tab header make transparent border for overlapping border

I have a border around my .tab-content and the same border around active .tabs. I've tried adding a transparent border on the bottom to no avail.
Is there a way to, where two borders overlap, have one override the other? Or is there a better way to accomplish this?
Here's a jsfiddle to show my basic set up.
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
border-bottom:transparent;
background-color: #aaa;
}
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>
You can use a pseudo element to create the bottom border, make it the same color as the background, and position it to cover the dark line.
.tab.active:after {
content: '';
border-bottom: 10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
}
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
}
.tab.active:after {
content: '';
border-bottom:10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
}
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>
Or just move the whole navbar 1px down.
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
bottom: -1px;
}
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
bottom: -1px;
}
/* .tab.active:after {
content: '';
border-bottom:10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
} */
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>

CSS Slanted Edges with outer border around edges

Is this possible at all using just CSS? I need to create two slant edges with an outer border but seeming that I created the slant edges with a border I am completely lost.
This is how far I got.
JSFIDDLE does not seem to want to load today??? but will post it on there as soon as possible :).
Here's the CSS:
.wrap {width:29%;}
.slider-header:before {
content:'';
border-top:20px solid white;
border-right: 20px solid #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:20px;
position: absolute;
top: 0;
left: 0;
height:100%;
width: 20px;
}
.slider-header {
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
background:#000000;
position:relative;
font-size:1em;
padding-left:1.5em;
width:200px;
float:right;
}
.slider-header2:before {
content:'';
border-bottom:20px solid white;
border-left: 20px solid #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:20px;
position: absolute;
top: 0;
right: 0;
height:100%;
width: 20px;
}
.slider-header2 {
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
background:#000000;
position:relative;
font-size:1em;
padding-left:1.5em;
width:200px;
float:left;
}
and the HTML:
<div class="wrap">
<div class="slider-header">
hey2
</div>
<div class="slider-header2">
hey
</div>
<div>
Hey everyone answers has been great especially Aequanox but i need this to work on IE8+ and if its IE7+ ill probably name my first born after you..
Here is achieved without adding any markup.
<div class="wrap">
<div class="slider-header">
hey1
</div>
<div class="slider-header2">
hey2
</div>
<div>
CSS is not optimized at all, just to achieve the deired effect.
.wrap{width:500px; padding:5px; display:block; overflow:hidden}
.wrap div{background:#333; color:#fff; width:235px; }
.wrap:after{
content:"";
display:block;
border-top:1px solid #333;
margin-top:-5px;
margin-left:265px;
width:235px;
}
.wrap:before{
content:"";
display:block;
border-bottom:1px solid #333;
position:absolute;
top:37px;
width:235px;
}
.slider-header{position:relative; float:left;}
.slider-header2{position:relative; float:right;}
.slider-header:before{
content:"";
display:block;
height:1px;
width:70px;
background:#333;
position:absolute;
left:225px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
}
.slider-header:after{
content:"";
display:block;
width:0;
height:0;
position:absolute;
top:0;
right:-20px;
border-right: 20px solid transparent;
border-top: 20px solid #333;
}
.slider-header2:before{
content:"";
display:block;
width:0;
height:0;
position:absolute;
top:0;
left:-20px;
border-left: 20px solid transparent;
border-bottom: 20px solid #333;
}
And here's the fiddle : http://jsfiddle.net/dG7mD/
It is possible to draw the shapes:
http://techcruser.blogspot.com/2011/08/draw-various-shapes-using-css.html
I was able to get the shapes without writing in them:
html:
<table>
<tr>
<td class="triangle-topleft">
button1
</td>
<td class="triangle-bottomright">
button2
</td>
</tr>
</table>
css:
.triangle-topleft {
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
*/}
.triangle-bottomright {
width: 0;
height: 0;
border-bottom: 100px solid red;
border-left: 100px solid transparent;
}
but honestly, I would use jquery to do my buttons or menus. It makes it easier in the long run.
What about using some simple hr's?
HTML:
<div id="elem"> <span>Text 1</span>
<span>Text 2</span>
<hr id="hr1" class="lines" />
<hr id="hr2" class="lines" />
<hr id="hr3" class="lines" />
</div>
CSS:
#elem {
height: 50px;
width: 320px;
background: black;
margin: 50px;
position: relative;
}
#elem > span {
box-sizing: border-box;
height: 100%;
width: 50%;
color: white;
display: block;
float: left;
padding: 0.2em 1.5em;
}
hr.lines {
height: 1px;
background-color: black;
color: black;
border: 3px solid white;
border-left: 0 none;
border-right: 0 none;
position: absolute;
margin: 0;
}
hr#hr1 {
-webkit-transform: rotate(-55deg);
-moz-transform: rotate(-55deg);
-o-transform: rotate(-55deg);
width: 70px;
top: 50%;
left: 50%;
margin-left: -40px;
margin-top: -3px;
}
hr#hr2 {
width: -webkit-calc(50% - 25px);
bottom: -7px;
left: 0;
}
hr#hr3 {
width: -webkit-calc(50% - 15px);
top: -7px;
right: 0;
}
Fiddle!