CSS Only Tooltip Arrow - With Background, Border & Box-shadow? - css

Tooltip CSS
.has-tooltip .tooltip {
position: absolute;
left: 50%;
top: -40px;
opacity: 0;
-webkit-transition: ease-out 300ms opacity;
-moz-transition: ease-out 300ms opacity 0ms;
-o-transition: ease-out 300ms opacity 0ms;
transition: ease-out 300ms opacity 0ms;
-webkit-transition-delay: 0ms;
pointer-events: none;
z-index: 9999;
}
.has-tooltip .tooltip span {
position: relative;
left: -50%;
display: block;
padding: 2px 8px;
font-size: 14px;
color: #fff;
white-space: nowrap;
background: rgba(45, 45, 45, 1);
border: 1px solid rgba(204,204,204,0.60);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
-moz-box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
}
View Live Example
What I Am Trying To Achieve
By only having one element, have a tooltip styled as seen in the link above with a tooltip arrow which also has the same look applied to appear to be one element. I've seen multiple which place another element within for the arrow however I'm hoping to achieve this without needing to do so.
Questions
How can I have a tooltip arrow which gives the impression it is part of the tooltip with the same styles applied.
Note: If you provide code, could you please fully explain what you have done so I can implement a top tip as well as a bottom tip.

You could use a pseudo element, i.e. ::before, and by rotate it 45 deg and positioning it about half its height from the bottom so it looks like an arrow.
a.has-tooltip {
position: relative;
transition: opacity 0.5s;
}
a.has-tooltip span {
position: absolute;
left: 20%; top: 50%;
transform: translate(0,-150%);
background: #333;
color: white;
border-radius: 10px;
box-shadow: 2px 2px 6px rgba(0,0,0,0.5);
padding: 10px;
white-space: nowrap;
opacity: 0;
transition: opacity 0.2s;
border: 4px solid #999;
}
a.has-tooltip span::before {
content: '';
position: absolute;
left: 20%; top: calc(100% - 10px);
height: 20px; width: 20px;
transform: rotate(45deg);
background: inherit;
box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
z-index: -1;
border: inherit;
border-width: 0 4px 4px 0;
}
a.has-tooltip:hover span {
opacity: 1;
}
<br><br><br>
<a href="#" class="has-tooltip" id="link"><span>Hi! I'm a tooltip!</span>
Hi! I'm a link!
</a>
Updated based on a comment
When one make a shadow like this, and as it is actually a square, their 2 shadows intersect
a.has-tooltip {
position: relative;
transition: opacity 0.5s;
}
a.has-tooltip span {
position: absolute;
left: 20%; top: -10%;
transform: translate(0,-150%);
background: #333;
color: white;
border-radius: 5px;
-webkit-box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
-moz-box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
box-shadow: 0px 0px 0px 6px rgba(0,0,0,0.50);
padding: 10px;
white-space: nowrap;
opacity: 0;
transition: opacity 0.2s;
border: 1px solid #FFFFFF;
}
a.has-tooltip span::before {
content: '';
position: absolute;
left: 10%; top: calc(100% - 10px);
height: 20px; width: 20px;
transform: rotate(45deg);
background: inherit;
-webkit-box-shadow: 4px 4px 0px 2px rgba(0,0,0,0.50);
-moz-box-shadow: 4px 4px 0px 2px rgba(0,0,0,0.50);
box-shadow: 4px 4px 0px 2px rgba(0,0,0,0.50);
z-index: -1;
border-right: 1px solid #FFFFFF;
border-bottom: 1px solid #FFFFFF;
}
a.has-tooltip:hover span { opacity: 1; }
<br><br><br><br>
<a href="#" class="has-tooltip" id="link"><span>Hi! I'm a tooltip!</span>
Hi! I'm a link!
</a>
To fix that is almost impossible, unless one use a SVG, though here is 2 possible solutions.
Give the shadow a non transparent color
a.has-tooltip {
position: relative;
transition: opacity 0.5s;
}
a.has-tooltip span {
position: absolute;
left: 20%; top: -10%;
transform: translate(0,-150%);
background: #333;
color: white;
border-radius: 5px;
-webkit-box-shadow: 0px 0px 0px 6px rgba(128,128,128,1);
-moz-box-shadow: 0px 0px 0px 6px rgba(128,128,128,1);
box-shadow: 0px 0px 0px 6px rgba(128,128,128,1);
padding: 10px;
white-space: nowrap;
opacity: 0;
transition: opacity 0.2s;
border: 1px solid #FFFFFF;
}
a.has-tooltip span::before {
content: '';
position: absolute;
left: 10%; top: calc(100% - 10px);
height: 20px; width: 20px;
transform: rotate(45deg);
background: inherit;
-webkit-box-shadow: 4px 4px 0px 2px rgba(128,128,128,1);
-moz-box-shadow: 4px 4px 0px 2px rgba(128,128,128,1);
box-shadow: 4px 4px 0px 2px rgba(128,128,128,1);
z-index: -1;
border-right: 1px solid #FFFFFF;
border-bottom: 1px solid #FFFFFF;
}
a.has-tooltip:hover span { opacity: 1; }
<br><br><br><br>
<a href="#" class="has-tooltip" id="link"><span>Hi! I'm a tooltip!</span>
Hi! I'm a link!
</a>
Use the other pseudo, ::after, as the shadow, which will be transparent. With this one need to play a little with the size of the main shadow and the position of the ::after pseudo.
a.has-tooltip {
position: relative;
transition: opacity 0.5s;
}
a.has-tooltip span {
position: absolute;
left: 20%; top: -10%;
transform: translate(0,-150%);
background: #333;
color: white;
border-radius: 5px;
-webkit-box-shadow: 0px 0px 0px 5px rgba(0,0,0,0.50);
-moz-box-shadow: 0px 0px 0px 5px rgba(0,0,0,0.50);
box-shadow: 0px 0px 0px 5px rgba(0,0,0,0.50);
padding: 10px;
white-space: nowrap;
opacity: 0;
transition: opacity 0.2s;
border: 1px solid #FFFFFF;
}
a.has-tooltip span::before {
content: '';
position: absolute;
left: 10%; top: calc(100% - 10px);
height: 20px; width: 20px;
transform: rotate(45deg);
background: inherit;
z-index: -1;
border-right: 1px solid #FFFFFF;
border-bottom: 1px solid #FFFFFF;
}
a.has-tooltip span::after {
content: '';
position: absolute;
left: calc(10% - 5px); top: calc(100% + 6px);
width: 0;
height: 0;
border-left: 16px solid transparent;
border-right: 16px solid transparent;
border-top: 16px solid rgba(0,0,0,0.50);
z-index: -2;
}
a.has-tooltip:hover span { opacity: 1; }
<br><br><br><br>
<a href="#" class="has-tooltip" id="link"><span>Hi! I'm a tooltip!</span>
Hi! I'm a link!
</a>

Related

How do I make this checkbox styling work in Edge?

I'm styling my checkboxes to look like toggle switches which works beautifully in Chrome, UC Browser, Safari for Windows and is a bit choppy in Firefox but acceptable. Unfortunately in Edge it doesn't work at all.
I've looked through the CSS properties I'm using and it appears as though all are supported by Edge so I don't understand what I'm missing.
.toggle{
width:34px;
height:16px;
border-radius:40px;
position:relative;
-webkit-appearance: none;
margin:2px 0 0 0px;
box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.4);
background: -webkit-linear-gradient(#c6c6c6,#e3e3e3);
cursor:hand;cursor:pointer;pointer:hand;
outline: 0;
}
.toggle:checked{
background: -webkit-linear-gradient(#77178F,#AD73BB);
box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.4);
}
.toggle:before {
content:'';
letter-spacing:1px;
color: rgba(0,0,0,.15);
font-size:10px;
font-weight:100;
text-shadow:1px 1px 1px rgba(255,255,255,1);
width:7px;
height:7px;
padding:2px;
top:2px;
left:2px;
position:absolute;
border-radius:40px;
background: linear-gradient(#ebebeb,#f1f1f1);
box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2),
-1px 1px 2px rgba(0, 0, 0, 0.3),
inset 1px 1px 1px #ffffff;
transition: all 0.4s;
}
.toggle:checked:before {
left:20px;
background:#f1f1f1;
}
.toggle:checked:after {
background: linear-gradient(#d8eec4,#5fa718);
box-shadow: inset -1px -1px 4px #417f0b,
inset 1px 1px 2px #5b9f1a;
}
<input type=checkbox class=toggle>
It looks to me like -webkit-appearance:none is not doing what it's supposed to (hide the original checkbox) but that also is supposedly supported.
If anybody has any experience with this issue and can give me some insight it would be much appreciated.
It's better to hide a checkbox, wrap it with another element (e.g. label) and add a sibling to the checkbox. You can find an example of checkbox-switch here https://www.w3schools.com/howto/howto_css_switch.asp.
Or you can adjust code below:
.toggle {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.toggle input[type=checkbox] {
opacity: 0; /* or use display: none; to hide default checkbox */
width: 0;
height: 0;
}
.toggle .slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(#ebebeb, #f1f1f1);
box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.4);
-webkit-transition: .4s;
transition: .4s;
}
.toggle .slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background: #ffffff;
-webkit-transition: .4s;
transition: .4s;
}
.toggle input[type=checkbox]:checked + .slider {
background: linear-gradient(#77178F,#AD73BB);
box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.4);
}
.toggle input[type=checkbox]:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
.toggle .slider.round {
border-radius: 34px;
}
.toggle .slider.round:before {
border-radius: 50%;
}
<label class="toggle">
<input type="checkbox">
<span class="slider round"></span>
</label>
You could add a label to meet your requirements as a workaround. In this way you could connect a label with a checkbox and apply the styles to the label instead of the checkbox itself.
Here is my testing code.
CSS.
.toggle {
visibility: hidden;
opacity: 0;
}
.toggle + label {
width: 34px;
height: 16px;
border-radius: 40px;
position: relative;
box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.4);
background: linear-gradient(#c6c6c6,#e3e3e3);
cursor: pointer;
outline: 0;
display: inline-block;
}
.toggle + label:before {
content: '';
letter-spacing: 1px;
color: rgba(0,0,0,.15);
font-size: 10px;
font-weight: 100;
text-shadow: 1px 1px 1px rgba(255,255,255,1);
width: 7px;
height: 7px;
padding: 2px;
top: 2px;
left: 2px;
position: absolute;
border-radius: 40px;
background: linear-gradient(#ebebeb,#f1f1f1);
box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2), -1px 1px 2px rgba(0, 0, 0, 0.3), inset 1px 1px 1px #ffffff;
transition: all 0.4s;
}
.toggle:checked + label {
background: linear-gradient(#77178F,#AD73BB);
box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.4);
}
.toggle:checked + label:before {
left: 20px;
background: #f1f1f1;
}
.toggle:checked + label:after {
background: linear-gradient(#d8eec4,#5fa718);
box-shadow: inset -1px -1px 4px #417f0b, inset 1px 1px 2px #5b9f1a;
}
HTML
<input type="checkbox" class="toggle" id="mycheckbox">
<label for="mycheckbox" />
Adding another flexible variation of the selected answer to the mix: https://codepen.io/hawatt/pen/MWKyJJZ
HAML
.toggle-switch
%input{type: 'checkbox', id: 'away-from-desk' }
%span.toggle-handle
%label{'for' => 'away-from-desk'} Away from desk
SCSS
$toggle-width: 2.8rem;
$toggle-height: 1.5rem;
$toggle-handle-diameter: calc(#{$toggle-height} * 0.8);
.toggle-switch {
position: relative;
display: flex;
align-items: center;
input {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: $toggle-width;
height: $toggle-height;
display: inline-flex;
position: relative;
border-radius: $toggle-height;
overflow: hidden;
outline: none;
border: none;
cursor: pointer;
background-color: #c0c0c0;
transition: all ease 0.3s;
z-index: 0;
text-indent: -5000px;
}
.toggle-handle {
pointer-events: none;
display: flex;
position: absolute;
z-index: 2;
width: $toggle-handle-diameter;
height: $toggle-handle-diameter;
background: #fff;
border-radius: 50%;
left: 0;
margin: 0 0.35rem;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
transition: all ease 0.3s;
}
input:checked,
input.enabled {
background-color: dodgerblue;
& + .toggle-handle {
left: calc(#{$toggle-width} - #{$toggle-handle-diameter} - 0.25rem);
}
}
label {
cursor: pointer;
}
}

Border to shadow CSS

How I can add border to shadow?
I wan't make something similar to this
Here's my code:
.btn {
margin: 10px;
}
.btn:active span {
transform: translate(0, 6px);
box-shadow: 0 -5px 0 blue;
transition: 0.3s;
}
.btn {
display: inline-block;
border-radius: 6px;
box-shadow: 0 6px 0 blue;
}
.btn span {
display: inline-block;
color:white;
padding: 10px 20px;
background: #3194c6;
border-radius: 4px;
transition: .2s ease-in-out;
}
Here's my jsfiddle
Use multiple shadows:
.btn {
margin:10px;
display: inline-block;
border-radius: 6px;
box-shadow: 0px 0px 0px 2px #000,
0 6px 0 red,
0px 6px 0px 2px #000,
0px 0px 0px 2px #000;
}
.btn span {
display: inline-block;
color: white;
padding: 10px 20px;
background: #3194c6;
border-radius: 4px;
transition: .2s ease-in-out;
}
<span>Press this!</span>

How to create button with rounded sides?

I need to create button like this
You can see a rounded borders on center of sides. I'm tried to do it with after and before classes, but it was tricky. Which solution is the cleanest? Also I'm done on dev resizeble button and it'll be better if this can be done as one figure, without absolute positioning or smth like that
body {
background-color: #000;
display: flex;
justify-content: center;
align-items: center;
}
button {
text-transform: uppercase;
background-color: #F9EFCA;
border: none;
padding: 20px 100px;
cursor: pointer;
letter-spacing: 1px;
border-bottom: 10px solid #ae9e5c !important;
box-shadow: inset 0 -1px 1px 0 rgba(0, 0, 0, .12), 0 10px 20px -5px rgba(0, 0, 0, .25);
font-size: 50px;
transition: .2s all;
position: relative;
border-radius: 10px;
}
button:hover,
button:active {
transition: .2s all;
border-bottom: none !important;
}
button:before,
button:after {
content: '';
position: absolute;
top: 9%;
bottom: 0;
height: 91%;
background: #F9EFCA;
width: 10px;
border-radius: 100%;
}
button:before {
left: -4px;
}
button:after {
right: -4px;
}
button:active:before,
button:active:after,
button:hover:before,
button:hover:after {
top: 9%;
bottom: 0;
height: 82%;
}
<button>Call me</button>
Codepen example
create a new button class and try this in your CSS:
.button_costum
{
margin: 10px auto;
font-size: 2.0rem;
padding: 1.25rem 2.5rem;
display: block;
background-color: // choose what you want
border: 1px solid transparent;
color: // choose what you want
font-weight: 300;
-webkit-border-radius: 3px;
border-radius: 20px; // in your case it shout be 25 or 30
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
try using the property on button
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
This would help you target the button corners without distorting the shape of the button itself.

CSS errors need fixing

I found a switch I'd like to use http://codepen.io/katmai7/pen/fyzuH . There is a working example at the above link but there are errors in the code and I ran this thru a code checker but wasn't able to figure out how to fix it. Do you know how to fix it? Here is what the code checker said:
Sorry! We found the following errors (6)
URI : TextArea
27 .wrap Parse Error .line{ position: absolute; top: 50px; width: 100%; border-top: 1px solid #1B1B1C; border-bottom: 1px solid #323334; }
28 .wrap Parse Error }
43 .switch Property user-select doesn't exist : none
45 .switch Lexical error at line 45, column 3. Encountered: "&" (38), after : "" &
48 :hover Parse Error .slide:after{ opacity: .05; }
49 :hover Parse Error Lexical error at line 51, column 3. Encountered: "&" (38), after : ""
html{
height: 100%;
}
body{
height: 100%;
background: #C1D1DA;
background: radial-gradient(ellipse at center, rgba(92,93,95,1) 0%,rgba(47,48,49,1) 100%);
}
.wrap{
position:relative;
margin: 100px auto;
width: 90px;
height: 100px;
border: 1px solid #1F1F20;
border-radius: 5px;
background: linear-gradient(to bottom, rgba(58,59,60,1) 0%,rgba(28,28,29,1) 100%);
box-shadow:inset 0 3px 4px -2px rgba(94,96,96, 1), 0 0 6px -1px rgba(0,0,0, .8), 0 2px 7px -1px rgba(0,0,0, .5);
.line{
position: absolute;
top: 50px;
width: 100%;
border-top: 1px solid #1B1B1C;
border-bottom: 1px solid #323334;
}
}
.switch{
position: relative;
display: block;
margin: 13px 17px;
width: 55px;
height: 25px;
border: 1px solid #1A1A1B;
border-radius: 20px;
background: linear-gradient(to bottom, rgba(31,31,32,1) 0%,rgba(58,58,58,1) 100%);
box-shadow: 0 1px 1px 0 rgba(130,132,134, .6), inset 0 4px 0 -3px rgba(0,0,0, .3);
cursor: pointer;
transition: box-shadow .5s ease .27s, border-color .5s ease .27s;
user-select: none;
&:hover{
.slide:after{
opacity: .05;
}
}
&.p2{
margin-top: 25px;
}
&:after{
display: block;
width: 100%;
height: 100%;
border-radius: 20px;
background: green;
background: linear-gradient(to bottom, rgba(186,101,82,1) 0%,rgba(215,151,101,1) 100%);background: linear-gradient(to bottom, rgba(186,101,82,1) 0%,rgba(215,151,101,1) 100%);
content: "";
opacity: 0;
transition: opacity .5s ease .27s;
}
/some context/
&:before{
position: absolute;
display: block;
width: 95%;
height: 60%;
border-radius: 20px;
background: #fff;
content: "";
opacity: .03;
}
.icon-off, .icon-eye-open{
position: absolute;
z-index: 2;
display: block;
line-height: 25px;
font-size: 18px;
}
.icon-eye-open{
left: 5px;
color: #EDD6CD;
text-shadow: 0 1px 0 #97614B;
}
.icon-off{
top: 1px;
right: 5px;
color: #6D6F70;
}
.slide{
position: absolute;
top: -1px;
left: -2px;
z-index:5;
width: 25px;
height: 25px;
border: 1px solid #171718;
border-radius: 50%;
background: linear-gradient(to bottom, rgba(64,65,66,1) 0%,rgba(30,30,31,1) 100%);
box-shadow:inset 0 1px 2px 0 rgba(93,94,95, .8), 1px 3px 5px -2px rgba(0,0,0, .7);
transition: left .4s ease-in, border-color .4s ease-in .1s;
&:after{
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
background: linear-gradient(to bottom, rgba(243,232,223,1) 0%,rgba(204,169,140,1) 100%);
content: "";
opacity: 0;
transition: opacity .4s ease .1s;
}
}
}
input[type=checkbox]{
display: none;
&:checked{
+ .switch{
border-color: #4D2318;
box-shadow: 0 1px 1px 0 rgba(130,132,134, .6), inset 0 4px 0 -3px rgba(0,0,0, .3), 0 0 15px 0 rgba(213,147,99, .7);
&:after{
opacity: 1;
}
.slide{
left: 29px;
border-color: #704F3F;
&:after{
opacity: 1;
}
}
}
}
}
You are using a CSS parser on LESS syntax, which will definitely throw errors.
LESS allows for selector nesting like this:
.wrap {
/* some css */
.line {
/* some more CSS */
}
}
You can't do this in pure CSS, which is why your CSS checker is throwing all these errors. The code is basically equivalent to:
.wrap { ... }
.wrap .line { ... }

Inside arrow on the right with outline border and boxshadow

I'm trying to add some css3 styles on an element, basing on an image model.
After many search, I've been able to have a some results, but not all I need.
You can see on the following image : http://soultherapy.free.fr/img/css3_need_screen.png
=> on the top : the effects I'm trying to reproduce in css3
=> on the bottom : the effects I was able to realize with css3 only : very very far from perfection ^^
As you can see, there are problems with border and shading of the right arrow...
Here is the html code :
<div class="span6">
the text<b></b>
</div>
And the css code :
.arrow-box, .arrow-box:hover {
position: relative;
display: inline-block;
font-weight: bold;
padding: 6px 12px 6px 30px;
margin: 10px 10px 10px -18px;
color: #fff !important;
background-color: #5e98ba;
-webkit-box-shadow: 3px 2px 4px rgba(0,0,0,.5);
-moz-box-shadow: 3px 2px 4px rgba(0,0,0,.5);
box-shadow: 3px 2px 4px rgba(0,0,0,.5);
outline: 1px solid #5e98ba;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
border:1px solid #c4c7c9;
border-left: 0;
}
.arrow-box:before{
content: ' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
top: 100%;
border-width: 5px 10px;
border-style: solid;
border-color: #315164 #315164 transparent transparent;
}
.arrow-box:after{
content: ' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
top: 0;
border-width: 10px 5px;
border-style: solid;
border-color: #5e98ba transparent transparent #5e98ba ;
}
.arrow-box b {
position: absolute;
width: 0;
height: 0;
right: -10px;
bottom: 0;
border-width: 10px 5px;
border-style: solid;
border-color: transparent transparent #5e98ba #5e98ba ;
}
Do you think what I'm trying to do is possible only with css3 ?
If it's the case, could you help me to find the correct css3 code.
Fiddle: http://jsfiddle.net/2cDnV/1/
I know my solution does not look exactly like your image but might help you to get started.
You can play around the code a bit to get what you want and to bring elegance to it.
You can find the jsFiddle here.
HTML:
<div class="marginer">
<div class="box">
<div class="boxIn">This is text</div>
<div class="boxArrowUp">
<div class="boxArrowUpIn"></div>
</div>
<div class="boxArrowDown">
<div class="boxArrowDownIn"></div>
</div>
</div>
</div>
CSS:
.marginer {
margin: 20px;
}
.boxIn {
float: left;
border: 1px solid #fff;
border-right: 0;
padding: 6px 12px 6px 30px;
box-shadow: 1px 2px 0px #5e98ba, 1px -1px 0px #5e98ba;
}
.box {
position: relative;
display: inline-block;
font-weight: bold;
margin: 10px 10px 10px -18px;
color: #fff !important;
background-color: #5e98ba;
-webkit-box-shadow: 3px 2px 4px rgba(0, 0, 0, .5);
-moz-box-shadow: 3px 2px 4px rgba(0, 0, 0, .5);
box-shadow: 8px 3px 6px rgba(0, 0, 0, .5);
}
.box:before {
content:' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
top: 100%;
border-width: 5px 10px;
border-style: solid;
border-color: #315164 #315164 transparent transparent;
}
.boxArrowUp {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
top: 0;
border-width: 10px 5px;
border-style: solid;
border-color: #5e98ba transparent transparent #5e98ba;
}
.boxArrowUpIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
top: -10px;
left: -5px;
border-top: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 0px 0px #5e98ba, 0px -1px 0px #5e98ba;
}
.boxArrowUpIn:after {
content:' ';
position: absolute;
width: 2px;
height: 20px;
top: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(28deg);
-webkit-transform:rotate(28deg);
-o-transform:rotate(28deg);
-ms-transform:rotate(28deg);
z-index: 2;
box-shadow: 3px 2px 4px rgba(0, 0, 0, .5);
}
.boxArrowDown {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
bottom: 0;
border-width: 10px 5px;
border-style: solid;
border-color: transparent transparent #5e98ba #5e98ba;
}
.boxArrowDownIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
bottom: -10px;
left: -5px;
border-bottom: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 2px 0px #5e98ba, 0px 0px 0px #5e98ba;
}
.boxArrowDownIn:after {
content:' ';
position: absolute;
width: 2px;
height: 19px;
bottom: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(332deg);
-webkit-transform:rotate(332deg);
-o-transform:rotate(332deg);
-ms-transform:rotate(332deg);
z-index: 2;
box-shadow: 1px 4px 3px rgba(0, 0, 0, .5);
}
I've played a bit with shadows and tranforms to achieve the result.
Let me know if it helped you.
Here is the final code to obtain exactly the same result as in the original image : http://jsfiddle.net/developpeuse_web/TSFMT/1/
HTML :
<div class="box">
<div class="left-shadow"></div>
<div class="boxIn"></div>
<div class="boxArrowUp">
<div class="boxArrowUpIn"></div>
</div>
<div class="boxArrowDown">
<div class="boxArrowDownIn"></div>
</div>
</div>
CSS :
.left-shadow {
position: absolute;
height: 100%;
width: 23px;
left: 0px;
top: 0px;
background-image: -webkit-gradient(linear, left top, right top, from(#333333), to(transparent));
background-image: -webkit-linear-gradient(left, #333333, transparent);
background-image: -moz-linear-gradient(left, #333333, transparent);
background-image: -o-linear-gradient(left, #333333, transparent);
background-image: linear-gradient(left, #333333, transparent);
opacity: 0.44;
filter : alpha(opacity=44);
}
.boxIn {
float: left;
border: 1px solid #fff;
width: 100px;
height: 20px;
border-right: 0;
padding: 6px 12px 6px 30px;
box-shadow: 1px 2px 0px #5e98ba, 1px -1px 0px #5e98ba;
}
.box {
position: relative;
display: inline-block;
font-weight: bold;
margin: 10px 10px 10px -18px;
color: #fff !important;
background-color: #5e98ba;
-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.45));
}
.box:before {
content:' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
top: 100%;
border-width: 5px 10px;
border-style: solid;
border-color: #315164 #315164 transparent transparent;
}
.boxArrowUp {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
top: 0;
border-width: 10px 5px;
border-style: solid;
border-color: #5e98ba transparent transparent #5e98ba;
}
.boxArrowUpIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
top: -10px;
left: -5px;
border-top: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 0px 0px #5e98ba, 0px -1px 0px #5e98ba;
}
.boxArrowUpIn:after {
content:' ';
position: absolute;
width: 2px;
height: 20px;
top: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(28deg);
-webkit-transform:rotate(28deg);
-o-transform:rotate(28deg);
-ms-transform:rotate(28deg);
z-index: 2;
}
.boxArrowDown {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
bottom: 0;
border-width: 10px 5px;
border-style: solid;
border-color: transparent transparent #5e98ba #5e98ba;
}
.boxArrowDownIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
bottom: -10px;
left: -5px;
border-bottom: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 2px 0px #5e98ba, 0px 0px 0px #5e98ba;
}
.boxArrowDownIn:after {
content:' ';
position: absolute;
width: 2px;
height: 19px;
bottom: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(332deg);
-webkit-transform:rotate(332deg);
-o-transform:rotate(332deg);
-ms-transform:rotate(332deg);
z-index: 2;
}
Thanks Harshad !
Thanks...of course it helped me a lot !
If it's not perfect, well it's very close :)
In complement, I've just found another way to generate shadow, by using "-webkit-filter: drop-shadow". So I've add this attribute to .box element, and remove the grey box-shadow on all other elements (.box, .boxArrowUpIn:after, .boxArrowDownIn:after ) : http://jsfiddle.net/developpeuse_web/TSFMT/
.marginer {
margin: 20px;
}
.boxIn {
float: left;
border: 1px solid #fff;
border-right: 0;
padding: 6px 12px 6px 30px;
box-shadow: 1px 2px 0px #5e98ba, 1px -1px 0px #5e98ba;
}
.box {
position: relative;
display: inline-block;
font-weight: bold;
margin: 10px 10px 10px -18px;
color: #fff !important;
background-color: #5e98ba;
/* -webkit-box-shadow: 3px 2px 4px rgba(0, 0, 0, .5);
-moz-box-shadow: 3px 2px 4px rgba(0, 0, 0, .5);
box-shadow: 8px 3px 6px rgba(0, 0, 0, .5); */
-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.45));
}
.box:before {
content:' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
top: 100%;
border-width: 5px 10px;
border-style: solid;
border-color: #315164 #315164 transparent transparent;
}
.boxArrowUp {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
top: 0;
border-width: 10px 5px;
border-style: solid;
border-color: #5e98ba transparent transparent #5e98ba;
}
.boxArrowUpIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
top: -10px;
left: -5px;
border-top: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 0px 0px #5e98ba, 0px -1px 0px #5e98ba;
}
.boxArrowUpIn:after {
content:' ';
position: absolute;
width: 2px;
height: 20px;
top: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(28deg);
-webkit-transform:rotate(28deg);
-o-transform:rotate(28deg);
-ms-transform:rotate(28deg);
z-index: 2;
/* box-shadow: 3px 2px 4px rgba(0, 0, 0, .5); */
}
.boxArrowDown {
content:' ';
position: absolute;
width: 0;
height: 0;
right: -10px;
bottom: 0;
border-width: 10px 5px;
border-style: solid;
border-color: transparent transparent #5e98ba #5e98ba;
}
.boxArrowDownIn:before {
content:' ';
position: absolute;
width: 10px;
height: 20px;
bottom: -10px;
left: -5px;
border-bottom: 1px solid #fff;
border-right: 0px;
box-shadow: 0px 2px 0px #5e98ba, 0px 0px 0px #5e98ba;
}
.boxArrowDownIn:after {
content:' ';
position: absolute;
width: 2px;
height: 19px;
bottom: -11px;
left: -1px;
background: #5e98ba;
border-left: 1px solid #fff;
-moz-transform:rotate(332deg);
-webkit-transform:rotate(332deg);
-o-transform:rotate(332deg);
-ms-transform:rotate(332deg);
z-index: 2;
/* box-shadow: 1px 4px 3px rgba(0, 0, 0, .5); */
}
Don't know if it's a better solution for browsers compatibility, but looks a little bit cleaner.
I think the last detail I have to do is to add an inner shadow on the left border, and it will be exactly what I need. I'll post the final code here.
Thanks very much !
Is it too late to enter the contest ?
The HTML
<div id="mysolution">MY SOLUTION<div id="arrow"></div></div>
The CSS
#mysolution {
color: red;
padding: 10px 9px 10px 25px;
position: relative;
display: block;
z-index: 1;
width: 170px;
height: 30px;
overflow: hidden;
}
#mysolution:after, #mysolution:before {
content: " ";
display: block;
left: -20px;
position: absolute;
width: 80%;
}
#mysolution:before {
z-index: -2;
height: 30%;
top: 11%;
-webkit-transform: skewX(-35deg);
background-image: linear-gradient(55deg, black, rgb(94, 152, 186) 30%);
border-right: 1px solid white;
border-top: 1px solid white;
box-shadow: 1.52px -1px 0px #5e98ba, 4px 4px 5px rgb(110, 110, 110);
}
#mysolution:after {
z-index: -1;
height: 28%;
bottom: 28.95%;
-webkit-transform: skewX(35deg);
background-image: linear-gradient(125deg, black, rgb(94, 152, 186) 30%);
padding-right: .8px;
border-right: 1px solid white;
border-bottom: 1px solid white;
box-shadow: 1.52px 1px 0px #5e98ba, 1.52px 0.5px 0px #5e98ba,-2px 4px 5px rgb(110, 110, 110);
}
#arrow {
position: absolute;
width: 0px;
height: 0px;
left: 0px;
top: 37px;
border-width: 5px 10px;
border-style: solid;
border-color: #315164 #315164 transparent transparent;
z-index: -3;
-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.45));
}
fiddle
Just trying to do it with less divs and less CSS. (And picking ideas from the work already done... :-)

Resources