transparent shape with arrow in upper corner - html

Please see the image below.
I want to add an arrow to the top right of a div which I am treating as editable input box.
Please help me how I can achieve this using CSS.
I cannot use a SVG since I need this as a div to show emoticons as images over it.
<div placeholder="Your message" id="Message">
...
</div>

You can do it like in the below snippet. The method used to achieve the shape is as given below:
The main div element only has a top, bottom and left border. The right border is nullified because the element and its arrows needs to be transparent. With a transparent arrow, if a right border is present that would also get displayed.
The arrow on the right is achieved using a skewed element placed with respect to the right edge of the shape.
The right border of the shape is achieved by using another pseudo-element whose size is the same as the height of the whole container - height of the arrow pseudo-element. This element is positioned with respect to the bottom right of the shape.
You can adjust the height and border-radius as required. I have set the positioning such that even a change in height/width of parent would not affect it.
div.shape {
position: relative;
width: 300px;
height: 100px;
padding: 4px;
margin-top: 20px;
border: 2px solid gray;
border-right: none; /* not required as the shape needs to be transparent */
border-radius: 8px; /* not required as the right border is done through pseudo element */
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
div.shape:before {
position: absolute;
content: '';
top: -2px; /* equal to border top of parent - no need to change*/
right: -6px; /* for positioning - no need to change*/
height: 15%; /* should be changed depending on height of arrow */
width: 10%; /* should be changed depending on width of arrow */
border-top: 2px solid gray;
border-right: 3px solid gray; /* thicker border because skew makes it thin */
/* to achieve the arrow like shape */
-webkit-transform-origin: bottom right;
-webkit-transform: skew(-45deg);
-moz-transform: skew(-45deg);
transform: skew(-45deg);
}
div.shape:after {
position: absolute;
content: '';
right: -6px; /* for positioning - no need to change*/
height: 85%; /* height of parent - height of arrow */
width: 2%; /* no need to change */
bottom: -2px; /* equal to border bottom of parent - no need to change*/
border-right: 2px solid gray;
border-bottom: 2px solid gray;
border-bottom-right-radius: 8px; /* for producing curve on bottom right */
}
/* Just for demo */
body {
background: -webkit-linear-gradient(0deg, crimson, indianred, purple);
background: -moz-linear-gradient(90deg, crimson, indianred, purple);
background: linear-gradient(90deg, crimson, indianred, purple);
}
<div class="shape">
Lorem Ipsum Dolor Sit Amet...
</div>
The arrow can be added to the left side by changing the positioning attributes and the skew direction (from positive angle to negative angle) like in the below snippet.
div.shape {
position: relative;
width: 300px;
height: 100px;
padding: 4px;
margin-top: 20px;
margin-left: 20px;
border: 2px solid gray;
border-left: none; /* not required as the shape needs to be transparent */
border-radius: 8px; /* not required as the right border is done through pseudo element */
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
div.shape:before {
position: absolute;
content: '';
top: -2px; /* equal to border top of parent - no need to change*/
left: -6px; /* for positioning - no need to change*/
height: 15%; /* should be changed depending on height of arrow */
width: 10%; /* should be changed depending on width of arrow */
border-top: 2px solid gray;
border-left: 3px solid gray; /* thicker border because skew makes it thin */
/* to achieve the arrow like shape */
-webkit-transform-origin: bottom right;
-webkit-transform: skew(45deg);
-moz-transform: skew(45deg);
transform: skew(45deg);
}
div.shape:after {
position: absolute;
content: '';
left: -6px; /* for positioning - no need to change*/
height: 85%; /* height of parent - height of arrow */
width: 2%; /* no need to change */
bottom: -2px; /* equal to border bottom of parent - no need to change*/
border-left: 2px solid gray;
border-bottom: 2px solid gray;
border-bottom-left-radius: 8px; /* for producing curve on bottom right */
}
/* Just for demo */
body {
background: -webkit-linear-gradient(0deg, crimson, indianred, purple);
background: -moz-linear-gradient(90deg, crimson, indianred, purple);
background: linear-gradient(90deg, crimson, indianred, purple);
}
<div class="shape">
Lorem Ipsum Dolor Sit Amet...
</div>

Filter: drop-shadow()
The compatibility is limited
Yet the effect is pretty cool :P
.inputcontainer {
display: inline-block;
position: relative;
filter: drop-shadow(0px 0px 5px black);
-webkit-filter: drop-shadow(0px 0px 1px black);
}
.input {
display: inline-block;
border: none;
border-radius: 10px;
border-top-right-radius: 0px;
width: 280px;
height: 50px;
background-color: white;
padding-left: 20px;
font-size: 20px;
}
.input:focus {
outline: none;
}
.arrow {
position: absolute;
display: inline-block;
top: 0;
right: -5px;
width: 20px;
height: 20px;
background-color: white;
transform: skew(-45deg);
z-index: -1;
}
<div class="inputcontainer">
<input type="text" class="input" placeholder="Your message"/>
<div class="arrow"></div>
</div>
Box-shadow:
Here the compatibility is a lot better
.inputcontainer {
display: inline-block;
position: relative;
filter: drop-shadow(0px 0px 5px black);
}
.input {
display: inline-block;
border: none;
border-radius: 10px;
border-top-right-radius: 0px;
width: 280px;
height: 50px;
background-color: white;
padding-left: 20px;
font-size: 20px;
box-shadow: 0px 0px 0px 2px gray;
}
.input:focus {
outline: none;
}
.arrow {
position: absolute;
display: inline-block;
top: 0;
right: -8px;
width: 20px;
height: 20px;
background-color: white;
transform: skew(-45deg);
box-shadow: 2px -2px 0px 0px gray;
}
<div class="inputcontainer">
<input type="text" class="input" placeholder="Your message"/>
<div class="arrow"></div>
</div>

Related

Can you put 2 circles inside of one Button [duplicate]

This question already has answers here:
Circle with two borders
(4 answers)
Closed 7 months ago.
I want to make a 1€ coin with CSS but I have the problem that I can't give it it's characteristic shape consisting of two circles. I don't want to use multiple divs for making the two circles because I want to have it as a Button. Is there any way to put 2 different shapes in one button tag or are you forced to use divs?
Here is my failed attempt at trying to do so:
.btnCircle1 {
height: 50px;
width: 50px;
border-radius: 50%;
background: red;
z-index: 100;
}
.btnCircle2 {
height: 100px;
width: 100px;
border-radius: 50%;
background: blue;
z-index: 1;
}
<button type="button" class="btnCircle1 btnCircle2"></button>
.btnCircle {
/* here just change one value, to change the other automatically */
/* for example you can use a responsive unit (that change often) like `vw` and the other element will automatically changed automatically */
--bigCirle-Height: 100px;
height: var(--bigCirle-Height);
width: var(--bigCirle-Height);
/* is always a perfect circle */
border-radius: var(--bigCirle-Height);
border: none; /* Remove default borders */
/* add this to make the ::before works */
position: relative;
}
.btnCircle::before {
/* change this value 1 means bigger, the smaller is the number (for example 0.7) the yellow circle is smaller */
/* using css variables and calculations the money it will be always responsive to the parent height */
--smallCirle-Height: calc(var(--bigCirle-Height) * 0.7);
content: '1€';
height: var(--smallCirle-Height);
width: var(--smallCirle-Height);
border-radius: var(--smallCirle-Height);
background: yellow;
/* this two lines will center the circle */
/* inset is like writing top: 50%, left: 50% */
inset: 50%;
transform: translate(-50%, -50%);
/* center the text inside circle */
display: grid;
place-content: center;
/* positioning absolutely */
position: absolute;
}
<button type="button" class="btnCircle"></button>
as A Haworth mentioned you, one way is using the before/after pseudo elements
here's an example:
.btnCircle {
position: relative;
border: none;
padding: 45px;
border-radius: 50%;
background: red;
}
.btnCircle::after {
position: absolute;
inset: 10px;
content: '';
background: blue;
border-radius: 50%;
}
<button class="btnCircle"></button>
One you can use background and border.
/*With background and border css start*/
.btnCircle1 {
position: relative;
background: transparent;
border: none;
z-index: 99;
line-height: 50px;
text-align: center;
width: 85px;
color: white;
background-color: blue;
border: 15px solid red;
border-radius: 100%;
}
/*With background and border css end*/
/*With pesudo element css start*/
.btnCircle1-psd {
position: relative;
background: transparent;
border: none;
z-index: 99;
line-height: 50px;
text-align: center;
width: 50px;
color: white;
}
.btnCircle1-psd::before,
.btnCircle1-psd::after {
content: "";
position: absolute;
top: 0;
left: 0;
display: inline-block;
height: 50px;
width: 50px;
border-radius: 50%;
background: red;
z-index: -1;
}
.btnCircle1-psd::after {
transform: scale(0.8);
background-color: blue;
}
/*With pesudo element css end*/
/*With radial gradient background color start*/
.btnCircle1-bg {
position: relative;
background: transparent;
border: none;
z-index: 99;
line-height: 50px;
text-align: center;
height: 85px;
width: 85px;
color: white;
border-radius: 100%;
background: rgb(255, 0, 0);
background: radial-gradient(circle, rgba(255, 0, 0, 1) 50%, rgba(0, 160, 255, 1) 50%);
}
/*With radial gradient background color end*/
/*With box inset shadow color start*/
.btnCircle1-shadow {
position: relative;
background: red;
border: none;
z-index: 99;
line-height: 50px;
text-align: center;
height: 85px;
width: 85px;
color: white;
border-radius: 100%;
-webkit-box-shadow: inset 0px 0px 0px 10px blue;
box-shadow: inset 0px 0px 0px 10px blue;
}
/*With box inset shadow color end*/
<h1> With background and border</h1>
<button type="button" class="btnCircle1">1$</button>
<h1> With radial gradient background color</h1>
<button type="button" class="btnCircle1-bg">1$</button>
<h1> With box inset shadow color</h1>
<button type="button" class="btnCircle1-shadow">1$</button>
<h1>With pesudo element <strong>before</strong> and <strong>after</strong>.</h1>
<button type="button" class="btnCircle1-psd">1$</button>

How to add background color only to main element and not :before and :after

I'm trying to style a heading to look like this:
The issue is that when I try to add a background color to the h2, it applies to the :before and :after content as well and spans the width of the page. I only want it applied to the h2.
I've tried adding a div inside the h2 and styling that instead of the h2.
.styled-heading {
text-align: center;
font-size: 32px;
background: black;
color: white;
}
.styled-heading:before {
content: " ";
display: inline-block;
margin: 0 0px 8px 0;
background-color: #999;
height: 3px;
width: 140px;
}
.styled-heading:after {
content: " ";
display: inline-block;
margin: 0 0 8px 00px;
background-color: #999;
height: 3px;
width: 140px;
}
<h2 class="styled-heading">Testing Testing</h2>
I would do this differently without pseudo element:
.styled-heading {
font-size: 32px;
color: white;
display:table; /* to make the element fit the content */
margin:auto; /* to center */
/* The border will be the space for the lines*/
border-left:50px solid transparent;
border-right:50px solid transparent;
padding:5px 10px;
background:
/* main background cover only the padding*/
linear-gradient(green,green) padding-box,
/* the Line cover also the border area (width:100% height:3px)*/
linear-gradient(blue,blue) center/100% 3px border-box no-repeat;
}
<h2 class="styled-heading">Testing Testing</h2>
You can also have each line alone if you want:
.styled-heading {
font-size: 32px;
color: white;
display:table; /* to make the element fit the content */
margin:auto; /* to center */
/* The border will be the space for the lines*/
border-left:50px solid transparent;
border-right:50px solid transparent;
padding:5px 10px;
background:
/* main background cover only the padding*/
linear-gradient(green,green) padding-box,
/* the Line cover also the border area*/
linear-gradient(blue,blue) left center/50% 3px border-box no-repeat,
linear-gradient(red,red) right center/50% 3px border-box no-repeat;
}
<h2 class="styled-heading">Testing Testing</h2>
Pseudo element is not the way to do this. Pseudo elements are part of the element. This works:
.header-pinch {
position: relative;
height: 3px;
width: 500px;
z-index: 1;
overflow: visible;
background: grey;
}
.header-pop {
position: relative;
z-index: 2;
background: black;
color: white;
width: fit-content;
padding: 5px;
margin: auto;
transform: translateY(-50%);
}
<br/>
<div class="header-pinch">
<h2 class="header-pop">TESTING</h2>
</div>

How to create a div with angled corners in CSS

I need to create div with angled corners (not rounded) with 2px border-width at my div:
I need a CSS-only solution
.center-link {
text-align: center;
}
.continue {
text-decoration: none;
border: 2px solid #26368d;
border-radius: 10px;
background-color: transparent;
margin: 0 auto;
padding: 10px 10px 9px;
font-family: 'Raleway';
text-transform: uppercase;
font-size: 11px;
font-weight: bold;
color: #26368d;
transition: all 0.5s ease;
}
<div class="center-link">Продолжить читать</div>
You could take a loook at gradient or single pixel image and background properties, background-size will help to draw the shapes
body {
text-align:center;
}
a {
display:inline-block;
text-decoration:none;
color:inherit;/* will use parent color if not reset */
margin:1em;
padding:0.5em 1em;
background: /* lets draw the background image via current color if text color is to be matched */
linear-gradient(45deg, transparent 0.5em, currentcolor 0.5em, currentcolor calc(0.5em + 2px), transparent calc(0.5em + 2px)),
linear-gradient(-45deg, transparent 0.5em, currentcolor 0.5em, currentcolor calc(0.5em + 2px), transparent calc(0.5em + 2px)),linear-gradient(225deg, transparent 0.5em, currentcolor 0.5em, currentcolor calc(0.5em + 2px), transparent calc(0.5em + 2px)),linear-gradient(-225deg, transparent 0.5em, currentcolor 0.5em, currentcolor calc(0.5em + 2px), transparent calc(0.5em + 2px)),
linear-gradient(to left, currentcolor, currentcolor) top no-repeat,
linear-gradient(to left, currentcolor, currentcolor) bottom no-repeat,
linear-gradient(to top, currentcolor, currentcolor) left no-repeat,
linear-gradient(to top, currentcolor, currentcolor) right no-repeat;
/* resize gradient/image in order to draw pieces needed */
background-size:
auto auto,
auto auto,
auto auto,
auto auto,
calc(100% - 1em - 6px ) 2px,
calc(100% - 1em - 6px) 2px,
2px calc(100% - 1em - 6px ),
2px calc(100% - 1em - 6px)
;
}
/* find out the purpose of currentcolor here */
:nth-child(1) {
color:purple
}
:nth-child(2) {
color:gold
}
:nth-child(3) {
color:pink
}
:nth-child(4) {
color:tomato
}
:nth-child(5) {
color:turquoise
}
/* increase size via padding ? */
:nth-child(6) {
padding:1em 2em;
color:gray
}
button link
button link
button link
button link
button link
button link
Demo pen to play with
You could use two span's for left and right border and then use :before and :after on those spans to create corners.
a {
text-decoration: none;
white-space: nowrap;
margin: 10px;
}
.el {
display: inline-flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid black;
border-bottom: 1px solid black;
margin: 50px;
position: relative;
}
span {
height: 20px;
position: relative;
}
span.left {
border-left: 1px solid black;
}
span.right {
border-right: 1px solid black;
}
.left {
margin-left: -10px;
}
.right {
margin-right: -10px;
}
span:before,
span:after {
content: '';
position: absolute;
width: 1px;
background: black;
height: 15px;
}
.left:before {
transform: rotate(40deg);
top: -13px;
left: 4px;
}
.left:after {
transform: rotate(-40deg);
bottom: -13px;
left: 4px;
}
.right:before {
transform: rotate(-40deg);
top: -13px;
right: 4px;
}
.right:after {
transform: rotate(42deg);
bottom: -13px;
left: -5px;
}
<div class="el">
<span class="left"></span>
Lorem ipsum dolor.
<span class="right"></span>
</div>
You should be able to keep a hit test accurate by using a skew along with a perspective, allowing you to create this bevelled button without affecting the user experience.
Something like adding:
transform: perspective(25px) rotateY(45deg);
A quick demo would be:
button {
border: 0;
border-top: 5px solid tomato;
border-bottom: 5px solid tomato;
color: tomato;
margin-left: 20px;
margin-right: 20px;
background: transparent;
padding: 10px;
outline: none;
padding-left: 50px;
padding-right: 50px;
position: relative;
cursor: pointer;
}
button:before {
content: "";
position: absolute;
top: -5px;
left: 100%;
height: 100%;
width: 20px;
background: inherit;
transform: perspective(25px) rotateY(45deg);
transform-origin: center left;
border-top: 5px solid tomato;
border-right: 8px solid tomato;
border-bottom: 5px solid tomato;
}
button:after {
content: "";
position: absolute;
top: -5px;
right: 100%;
height: 100%;
width: 20px;
background: inherit;
transform: perspective(25px) rotateY(-45deg);
transform-origin: center right;
border-top: 5px solid tomato;
border-left: 8px solid tomato;
border-bottom: 5px solid tomato;
}
<button>Button</button>
As a side note, this solution can be shortened and made a lot more efficient by placing the duplicate rules within a single selector (button:before, button:after{})

Link with border and down triangle transparent

I can't find what I need. I have this code
<hgroup id="subheader">
<h1>lorem ipsum</h1>
<h2>ipsum lorem</h2>
read More
</hgroup>
I want the link to have a border with a down triangle at the bottom. But it has to be transparent, because it goes in front of an image. Is that possible?
The shape given in question is a bit complex to achieve with full transparency because of the area cut by the arrow having to be transparent too. Because of this, the techniques that are generally used for creating such tool-tip like shapes cannot be used as-is here. However, there is a still a way to achieve it using CSS and it is as follows:
Use the parent hgroup for the shape with borders on top, left and right and add border-radius. Don't add any border to the bottom because then cutting the space for the arrow would be tough.
Use two pseudo elements (:before and :after) which have the same height as the parent but lesser width such that they produce a tiny gap when positioned absolutely with respect to parent. Add border-bottom alone to these pseudo-elements.
Add a pseudo-element for the arrow on the arrow-down element (a) and create the arrow using rotate(45deg) transforms instead of using the border trick. The transform method is very helpful for creating transparent arrows. Position this arrow again absolutely with respect to the parent.
As we are dealing with transforms, triangle shapes etc the position values need to be calculated based on Math theorems.
* {
box-sizing: border-box;
}
.container {
height: 300px;
width: 500px;
background: url(http://lorempixel.com/500/300/nature/2);
padding: 10px;
}
#subheader {
position: relative;
width: 400px;
height: auto;
border: 1px solid black;
border-bottom: none;
border-radius: 12px;
padding: 10px;
}
.arrow-down{
display: inline-block;
}
.arrow-down:after {
position: absolute;
content: '';
bottom: -10px; /* half the height of the element */
left: 50px; /* some aribitrary position */
height: 20px;
width: 20px;
transform: rotate(45deg);
transform-origin: 50% 50%; /* rotate around center which is at 60px from left */
border-right: 1px solid black;
border-bottom: 1px solid black;
}
#subheader:after {
position: absolute;
content: '';
left: 74px; /* center point of arrow + 1/2 of hypotenuse */
height: 100%;
width: calc(100% - 74px); /* 100% - value of left */
bottom: 0px;
border-bottom: 1px solid black;
border-bottom-right-radius: inherit; /* same border-radius as parent */
}
#subheader:before {
position: absolute;
content: '';
height: 100%;
width: 46px; /* center point of arrow - 1/2 of hypotenuse */
left: 0px;
bottom: 0px;
border-bottom: 1px solid black;
border-bottom-left-radius: inherit; /* same border-radius as parent */
}
<div class='container'>
<hgroup id="subheader">
<h1>lorem ipsum</h1>
<h2>ipsum lorem</h2>
Read More
</hgroup>
</div>
Here is a working version of what you're after.
HTML
<div style="display:none" class="tri-down">Your Content will go into this fancy tri-down</div>
CSS --- I ADDED a background img to show that its transparent as you said that you were going to be having an image behind it.
body {
background: #333 url("http://a2.files.readwrite.com/image/upload/c_fit,cs_srgb,dpr_1.0,q_80,w_620/MTIyMzI3NDY5NDAyMzg1Njg5.jpg") fixed;
}
.tri-down {
/* Styling block element, not required */
position: relative;
margin-bottom: 2em;
padding: 1em;
width: 75%;
border: 1px solid #999;
background: #f3f3f3;
border-radius:5px;
opacity: 0.5;
/*you may want to set the z-index level of your tri-down box.
z-index: 100;
*/
}
/* Required for Down Triangle */
.tri-down:before, .tri-down:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-color: transparent;
border-bottom: 0;
}
/* Stroke */
.tri-down:before {
bottom: -16px;
left: 21px;
/* If 1px darken stroke slightly */
border-top-color: #777;
border-width: 16px;
}
/* Fill */
.tri-down:after {
bottom: -15px;
left: 22px;
border-top-color: #f3f3f3;
border-width: 15px;
}
JSFIDDLE HERE
http://jsfiddle.net/LZoesch/dk43s2qz/
You will want to hide the DIV that is going to house your content. I added it to the above HTML code.
style="display:none"
Then you want to call the link on click and toggle the div class tri-down on/off
<script type="text/javascript">
$(function(){
$('#').click(function(){
$('#').toggle();
$('#').toggle();
});
});
</script>
Here is your orignal code.
<hgroup id="subheader">
<h1>lorem ipsum</h1>
<h2>ipsum lorem</h2>
read More
</hgroup>
If you dont want to set the opacity if your div, you can also try this below.
body {
background: url(http://a2.files.readwrite.com/image/upload/c_fit,cs_srgb,dpr_1.0,q_80,w_620/MTIyMzI3NDY5NDAyMzg1Njg5.jpg);
font-family: sans-serif;
text-align: center;
}
body > div {
color: #000;
margin: 50px;
padding: 15px;
position: relative;
}
.tri-down {
border: 5px solid #000;
content: "";
position: absolute;
}
you can try this one:
.tri-down {
/* Styling block element, not required */
position: relative;
margin-bottom: 2em;
padding: 1em;
border: 1px solid #999;
background: #f3f3f3;
border-radius:5px;
}
/* Required for Down Triangle */
.tri-down:before, .tri-down:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-color: transparent;
border-bottom: 0;
}
/* Stroke */
.tri-down:before {
bottom: -16px;
left: 21px;
/* If 1px darken stroke slightly */
border-top-color: #777;
border-width: 16px;
}
/* Fill */
.tri-down:after {
bottom: -15px;
left: 22px;
border-top-color: #f3f3f3;
border-width: 15px;
}
DEMO
You may need to overlay two images and absolutely position them. Like something along the lines of:
body{
padding:2em;
}
#subheader h1{
font-size:1.5em;
margin-top:0;
}
#subheader h2{font-size:1.2em;}
#subheader
{
position: relative;
max-width:300px;
min-height:1.5em;
padding: 20px;
background: #FFFFFF;
border: #dedede solid 2px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
#subheader:after
{
content: "";
position: absolute;
bottom: -19px;
height:13px;
widht:12px;
left: 10%;
border-style: solid;
border-width: 20px 13px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
}
#subheader:before
{
content: "";
position: absolute;
bottom: -22.5px;
left: calc(10.5% - 3px) ;
border-style: solid;
border-width: 23px 15px 0px;
border-color: #dedede transparent;
display: block;
width: 0;
z-index: 0;}
Like in this pen

Issues with border left and border top together

I am trying to add a border left to my selected buttons but there seems to be something odd happening I can't figure out.
You can see it in this JSFiddle.
The blue border on the left seems to have an odd 1px above it? It just doesnt sit perfectly square as i would have hoped.
HTML:
<div id="sidebarnav">
<br>
<div class="button-selected">Blog</div>
</div>
CSS:
#sidebarnav {
width:250px;
background-color:#202020;
height: 100%;
float:left;
position:fixed;
border-right: 1px solid #bbb;
}
.button-selected {
text-align:left;
width: 236;
padding-left: 10px;
padding-top: 6px;
padding-bottom: 6px;
background-color:#161616;
color: #fff;
border-top: 1px solid #0A0A0A;
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.04) inset;
overflow:auto;
cursor: pointer;
border-left: 4px solid #3498db;
}
You could work around the corner seam issue by adding a pseudo-element that acts like a border. Something like the following:
.button-selected {
/* all of your original styling here */
position: relative; /* relative positioning required for position
absolute on pseudo element */
padding-left: 14px; /* 4px of padding added to compensate for
width of pseudo element */
}
.button-selected:after {
content: '';
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 4px; /* width of desired 'border' effect */
background: #3498db;
}
Updated example of your jsfiddle here.