Make a right outer curved layer for paragraph with CSS - html

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>

Related

CSS - Rounded concave corners for compound layout

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>

Title with lines filling remaining space on both sides

I've been asked to create this title, purely with css, Is it even possible?
The background of the text needs to remain transparent, the h2 needs to span the width of any container and have the left and right borders fill automatically the remaining space.
h2 {
font-size:42px;
line-height:48px;
width:100%;
overflow: hidden;
&:before {
content:'';
position:relative;
padding-left:50px;
padding-right:10px;
margin-right:10px;
margin-bottom:10px;
background:red;
height:3px;
display:inline-block;
}
&:after {
content:'';
margin-left:10px;
width:100%;
background:red;
height:3px;
display:inline-block;
}
}
The left side is easy, however I'm stuck on the right side.
https://jsfiddle.net/kab5qtbb/
I can't seem to figure out how to only make the right line fill the remaining space on the right of the container.
You can use margin-right:-100%; and vertical-align:middle; on the :after pseudo element. (Based on this answer: Line separator under text and transparent background) :
h2 {
font-size: 42px;
line-height: 48px;
width: 100%;
overflow: hidden;
}
h2:before, h2:after {
content: '';
display: inline-block;
vertical-align:middle;
width:50px;
height:3px;
border-top:1px solid #fff;
border-bottom:1px solid #fff;
}
h2:after {
width:100%;
margin-right: -100%;
}
/**** FOR THE DEMO ***/
body{background-image: url('https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg');background-repeat:no-repeat;background-size:cover;color:#fff;}
<h2>HEALTH BENEFITS</h2>
<h2>HEALTH</h2>
Note that I also simplified your CSS.
If you are not too fussed about absolute positioning, you can do
h2 {
font-size:42px;
line-height:48px;
width:100%;
overflow: hidden;
&:before {
content:'';
position:relative;
padding-left:50px;
padding-right:10px;
margin-right:10px;
margin-bottom:10px;
border-top:1px solid #000;
border-bottom:1px solid #000;
height:3px;
display:inline-block;
}
&:after {
content:'';
margin-left:10px;
width:50%;
height:3px;
position:absolute;
border-top:1px solid #000;
border-bottom:1px solid #000;
top:60px;
}
}
will need tweaking but in jsfiddle this gets you what you need
Here is solution using display: table;
and display: table-cell;
The lines on the side grow and shrink after the content of the header.
.headline {
display: table;
line-height: 3px;
white-space: nowrap;
}
.headline:before {
width: 20%;
height: 2px;
margin-top: 20px;
border-right: 10px solid transparent;
}
.headline:after {
width: 80%;
border-left: 10px solid transparent;
}
.headline:before,
.headline:after {
content: '';
display: table-cell;
border-top: 1px solid black;
border-bottom: 1px solid black;
}
<h2 class="headline">
Headline
</h2>
<h2 class="headline">
Headline thats longerrrrrrrrrrrrrrrrr
</h2>
<style type="text/css">
h2 {
background-image:url(\.give url....);
font-size: 42px;
line-height: 48px;
width: 100%;
overflow: hidden;
}
h2:before {
content: '';
position: relative;
padding-left: 50px;
padding-right: 10px;
margin-right: 10px;
margin-bottom: 10px;
background: red;
height: 3px;
display: inline-block;
}
h2:after {
content: '';
margin-right: -100%;
width: 100%;
background: red;
height: 3px;
display: inline-block;
vertical-align:middle;
}
</style>
the html is:-
you also need to add background image or to use css3-gradients.
This is what Im using :)
https://jsfiddle.net/v7gze6ox/2/
fieldset {
border: 0px;
border-top: 3px solid red;
display: block;
padding-left: 25px;
padding-right: 25px;
width: 100%;
}
fieldset h2 {
margin: 10px;
color: white;
}
.bg {
background: url("http://images.all-free-download.com/images/graphiclarge/abstract_vector_green_background_277778.jpg");
}
<div class="bg">
<fieldset>
<legend align="right">
<h2>Text</h2>
</legend>
</fieldset>
</div>

Arrow not showing properly in CSS

I am trying to achieve the arrow pointing downwards...
right now its showing as trapezium there is some problem in CSS arrow code...
providing my code below.....
Output
https://docs.google.com/file/d/0B3IBJKENGE7RRFR1WHZDYTF6LTQ/edit
<div class="icon__controls__controls">
<div><i class="zoom-out"></i>
<i class="icon-threesixty"></i>
</div>
</div>
CSS :
.icon__controls__controls {
float: left;
display: block;
margin-right: 2.1276595745%;
width: 36.170212766%;
margin-left: 38.2978723404%;
margin-top: 10px;
margin-bottom: 30px;
text-align: center;
}
.icon__controls__controls:last-child {
margin-right: 0;
}
.icon__controls__controls [class^=icon-] {
font-size: 20px;
font-size: 1.25rem;
display: inline-block;
vertical-align: baseline;
zoom: 1;
*display: inline;
*vertical-align: auto;
color: #666;
margin: 0 5px;
vertical-align: top;
}
.icon__controls__controls .zoom-out {
color: red;
}
.icon__controls__controls:after {
display: none;
content: '';
z-index: 3;
border: 50px solid transparent;
/* border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black; */
}
.icon__controls__controls:after {
border-top-color: #ef6f00;
}
.icon__controls__controls.active:after {
display: block;
}
LIVE DEMO
This as basically all what you need to understand how it works:
STYLE:
.arrow{
width:20px;
height:20px;
position:relative;
}
.arrow:before{
content:'';
position:absolute;
top:0;
left:0;
width:0;
height:0;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-bottom:0px solid transparent;
border-top:20px solid orange;
}
HTML:
<div class=arrow><div>
if you want it to point up just switch topand bottom
border-top:0px solid transparent;
border-bottom:20px solid orange;
Same for leftand right.
I hope this will help you understanding how arrow are created.
Basic sample :
<div class="arrowBorder"></div>
.arrowBorder {
height : 0px;
width : 0px;
border-top: 50px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
}
http://jsbin.com/qusecu/4/watch?html,css,output
see more - CSS clipping or masking
You should find the below bit more simpler
css
.arrow{
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-o-box-sizing:border-box;
-ms-box-sizing:border-box;
width:20px;
height:20px;
position:relative;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-bottom:20px solid transparent;
border-top:20px solid orange;
}
html
<div class=arrow><div>

CSS custom shape button with two colors

I am struggling to create this "button" using CSS.
I also would like to be able to add the text "ABI" and "12/19" manually in my HTML so I can change it.
Attached the result I would like to have with the dimensions.
Thanks for your help.
I had fun creating it, it is not perfect and you will need some tweaking to get it exacly like the image but it should get you on the right path :
FIDDLE DEMO
html:
<div id="abi">ABI</div>
<div id="number">12/19</div>
CSS
div{
float:left;
height:60px;
line-height:60px;
font-size:20px;
margin:0;
padding:0;
}
#abi{
width:75px;
background:gray;
color:blue;
padding-left:25px;
position:relative;
z-index:2;
-webkit-border-radius: 5px 0 0 5px;
border-radius: 5px 0 0 5px;
}
#abi:after{
content:"";
position:absolute;
right:-10px;
top: 19px;
width: 0;
height: 0;
border-top: 11px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid gray;
}
#number{
width:155px;
text-align:right;
padding-right:25px;
background:blue;
color:gray;
-webkit-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
}
Something
LIKE THIS?
HTML
<div class='button'>ABI
<div>12/19</div>
</div>
CSS
* {
margin:0;
padding:0;
box-sizing:border-box;
}
.button, .button div {
color:grey;
background:#007bff;
display:inline-block;
line-height:60px;
font-size:20px;
}
.button div {
padding-right:25px;
padding-left:25px;
width:180px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-topright: 5px;
-moz-border-radius-bottomright: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
z-index:1;
text-align:left;
position:relative;
}
.button {
color:#007bff;
background:grey;
padding-left:25px;
width:280px;
text-align:right;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
position:relative;
z-index:1;
}
.button div:after {
content:'';
display:block;
position:absolute;
left:0px;
top:20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 0 10px 14px;
border-color: transparent transparent transparent grey;
z-index:0;
}
Also did one for fun.. :)
Fiddle
CSS
.btn{
position: relative;
border-radius: 10px;
display: table;
font-size: 35px;
font-family: Verdana, sans-serif;
width: 280px;
height: 60px;
background: #2a2c2b;
}
.left{
position: relative;
padding-left: 25px;
color: #0ebfe9;
display: table-cell;
width: 100px;
vertical-align: middle;
}
.right{
color: #2a2c2b;
display: table-cell;
width: 180px;
vertical-align: middle;
padding-left: 14px;
padding-right: 25px;
}
.left:after
{
height: 0px;
content: '';
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #2a2c2b;
position: absolute;
left:90px;
}
HTML
<div class="btn"><span class="left">ABI</span><span class="right">| 12/19</span></div>
(background of btn are gradients, couldn't get them in the code here..)
Looked like fun, had to try it myself: http://jsfiddle.net/8SUX6/1/
Change href="#" to a link, to make it one or add a onclick event for it to execute JS.
ABI <span>12/19</span>
#button {
font-weight: 600;
height: 60px;
width: 60px; /* 60 + 25 + 15 = 100 */
display: block;
text-decoration: none;
background: #2A2C2B;
color: #0EBFE9;
position: absolute;
border-radius: 5px 0 0 5px;
font-family: Segoe UI;
font-size: 40px;
padding-left: 25px;
padding-right: 15px;
}
#button:before {
left: 93px;
top: 10px;
z-index: 3;
content:"";
position: absolute;
width: 0;
height: 0;
border-left: 20px solid #2A2C2B;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
#button span {
top: 0;
letter-spacing: 2px;
color: #2A2C2B;
position: absolute;
z-index: 2;
height: 60px;
width: 155px; /* 155 + 25 = 180px */
background: #0EBFE9;
position: absolute;
left: 100px;
border-radius: 0 5px 5px 0;
padding-right: 25px;
text-align: right;
}
The following can be the css
*{
margin:0;
padding:0;
}
div{
float:left;
margin-top:10px;
font-size:20px;
font-weight:bold;
text-align:center;
height:60px;
}
.abi{
margin-left:10px;
width:100px;
background:#2A2C2B;
color:#0EBFE9;
border-radius:10px 0 0 10px;
}
.abi>p,.num>p{
padding-top:15px;
}
.num{
color:#2A2C2B;
background:#0EBFE9;
margin-right:10px;
width:180px;
border-radius:0 10px 10px 0;
}
.abi:after{
border-bottom: 10px solid transparent;
border-left: 10px solid #2A2B2C;
border-top: 11px solid transparent;
content: "";
position: absolute;
left: 110px;
top: 29px;
}
the following is the html
<div class="abi"><p>ABI</p></div>
<div class="num"><p>12/19</p></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!