Draw an X in CSS - html

I've got a div that looks like a orange square
I'd like to draw a white X in this div somehow so that it looks more like
Anyway to do this in CSS or is it going to be easier to just draw this in Photoshop and use the image as the div background? The div code just looks like
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}

You want an entity known as a cross mark:
http://www.fileformat.info/info/unicode/char/274c/index.htm
The code for it is ❌ and it displays like ❌
If you want a perfectly centered cross mark, like this:
try the following CSS:
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
position: relative;
}
div:after {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
content: "\274c"; /* use the hex value here... */
font-size: 50px;
color: #FFF;
line-height: 100px;
text-align: center;
}
See Demo Fiddle
Cross-Browser Issue
The cross-mark entity does not display with Safari or Chrome. However, the same entity displays well in Firefox, IE and Opera.
It is safe to use the smaller but similarly shaped multiplication sign entity, × which displays as ×.

single element solution:
body{
background:blue;
}
div{
width:40px;
height:40px;
background-color:red;
position:relative;
border-radius:6px;
box-shadow:2px 2px 4px 0 white;
}
div:before,div:after{
content:'';
position:absolute;
width:36px;
height:4px;
background-color:white;
border-radius:2px;
top:16px;
box-shadow:0 0 2px 0 #ccc;
}
div:before{
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
transform:rotate(45deg);
left:2px;
}
div:after{
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
transform:rotate(-45deg);
right:2px;
}
<div></div>

Yet another pure CSS solution (i.e. without the use of images, characters or additional fonts), based on #Bansoa is the answer's answer .
I've simplified it and added a bit of Flexbox magic to make it responsive.
Cross in this example automatically scales to any square container, and to change the thickness of its lines one have just to tune height: 4px; (to make a cross truly responsive, you may want to set the height in percents or other relative units).
div {
position: relative;
height: 150px; /* this can be anything */
width: 150px; /* ...but maintain 1:1 aspect ratio */
display: flex;
flex-direction: column;
justify-content: center;
}
div::before,
div::after {
position: absolute;
content: '';
width: 100%;
height: 4px; /* cross thickness */
background-color: black;
}
div::before {
transform: rotate(45deg);
}
div::after {
transform: rotate(-45deg);
}
<div></div>

You can make a pretty nice X with CSS gradients:
demo: https://codepen.io/JasonWoof/pen/rZyRKR
code:
<span class="close-x"></span>
<style>
.close-x {
display: inline-block;
width: 20px;
height: 20px;
border: 7px solid #f56b00;
background:
linear-gradient(45deg, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 43%,#fff 45%,#fff 55%,rgba(0,0,0,0) 57%,rgba(0,0,0,0) 100%),
linear-gradient(135deg, #f56b00 0%,#f56b00 43%,#fff 45%,#fff 55%,#f56b00 57%,#f56b00 100%);
}
</style>

Yet another attempt... this one uses ×. A lot of the examples on this page only show for me as a box, but × works
HTML
<div class="close"></div>
CSS
.close {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
.close:after {
position:relative;
content:"\d7";
font-size:177px;
color:white;
font-weight:bold;
top:-53px;
left:-2px
}
JSFIDDLE

You could just put the letter X in the HTML inside the div and then style it with css.
See JSFiddle: http://jsfiddle.net/uSwbN/
HTML:
<div id="orangeBox">
<span id="x">X</span>
</div>
CSS:
#orangeBox {
background: #f90;
color: #fff;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 2em;
font-weight: bold;
text-align: center;
width: 40px;
height: 40px;
border-radius: 5px;
}

You can use the CSS property "content":
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
div:after {
content: "X";
font-size: 2em;
color: #FFF;
}
Like this:
http://jsfiddle.net/HKtFV/

#x{
width: 20px;
height: 20px;
background-color:orange;
position:relative;
border-radius:2px;
}
#x::after,#x::before{
position:absolute;
top:9px;
left:0px;
content:'';
display:block;
width:20px;
height:2px;
background-color:red;
}
#x::after{
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#x::before{
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
<div id=x>
</div>

I love this question! You could easily adapt my code below to be a white × on an orange square:
Demo fiddle here
Here is the SCSS (which could easily be converted to CSS):
$pFontSize: 18px;
p {
font-size: $pFontSize;
}
span{
font-weight: bold;
}
.x-overlay,
.x-emoji-overlay {
position: relative;
}
.x-overlay,
.x-emoji-overlay {
&:after {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
color: red;
text-align: center;
}
}
.x-overlay:after {
content: '\d7';
font-size: 3 * $pFontSize;
line-height: $pFontSize;
opacity: 0.7;
}
.x-emoji-overlay:after {
content: "\274c";
padding: 3px;
font-size: 1.5 * $pFontSize;
line-height: $pFontSize;
opacity: 0.5;
}
.strike {
position: relative;
display: inline-block;
}
.strike::before {
content: '';
border-bottom: 2px solid red;
width: 110%;
position: absolute;
left: -2px;
top: 46%;
}
.crossed-out {
/*inspired by https://www.tjvantoll.com/2013/09/12/building-custom-text-strikethroughs-with-css/*/
position: relative;
display: inline-block;
&::before,
&::after {
content: '';
width: 110%;
position: absolute;
left: -2px;
top: 45%;
opacity: 0.7;
}
&::before {
border-bottom: 2px solid red;
-webkit-transform: skewY(-20deg);
transform: skewY(-20deg);
}
&::after {
border-bottom: 2px solid red;
-webkit-transform: skewY(20deg);
transform: skewY(20deg);
}
}

You could do this by styling an "x"
text-align: center;
font-size: 120px;
line-height: 100px;
color: white;
font-family: monospace;
http://jsfiddle.net/Ncvyj/1/

Here is a single div and dynamic size version without using pseudo element.
body {
display: flex;
gap: 30px;
}
.x {
--color: #444;
--l: 5px; /* line-width */
width: 50px;
height: 50px;
background: linear-gradient(to top right, transparent calc(50% - var(--l) / 2), var(--color) calc(50% - var(--l) / 2) calc(50% + var(--l) / 2), transparent calc(50% + var(--l) / 2)),
linear-gradient(to bottom right, transparent calc(50% - var(--l) / 2), var(--color) calc(50% - var(--l) / 2) calc(50% + var(--l) / 2), transparent calc(50% + var(--l) / 2));
--clip-path: polygon(var(--l) 0%, calc(100% - var(--l)) 0%, 100% var(--l), 100% calc(100% - var(--l)), calc(100% - var(--l)) 100%, var(--l) 100%, 0% calc(100% - var(--l)), 0% var(--l));
-webkit-clip-path: var(--clip-path);
clip-path: var(--clip-path);
}
<div class="x"></div>
<div class="x" style="--l: 10px;"></div>
<div class="x" style="--l: 15px; --color: red"></div>
<div class="x" style="--l: 15px; --color: dodgerblue; width: 100px; height: 100px;"></div>

HTML
<div class="close-orange"></div>
CSS
.close-orange {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
.close-orange:before,.close-orange:after{
content:'';
position:absolute;
width: 50px;
height: 4px;
background-color:white;
border-radius:2px;
top: 55px;
}
.close-orange:before{
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
transform:rotate(45deg);
left: 32.5px;
}
.close-orange:after{
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
transform:rotate(-45deg);
left: 32.5px;
}
https://jsfiddle.net/cooperwebdesign/dw4xd289/

A modern answer with good browser support.
<span>×</span>
This technically puts the multiplication symbol there, but no one will really notice (found some websites that have a popup box and most use this for the x button).
If you need more control you can style it with color opacity etc...
example (index.html)
<span class="x-button">×</span>
styles.css
span.x-button {
color:gray;
opacity:0.7;
font-size:1.5em;
}
Result (first example)
<span>&times</span>
Result (2nd example)
span {
color:gray;
opacity:0.7;
font-size:1.5em;
}
<span class="x-button">×</span>
Note: you can highlight this unlike other solutions, but this may not be desirable depending on the application. You can solve this in pure css too, just add
user-select:none;
-webkit-user-select:none;

This is an adaptable version of the amazing solution provided by #Gildas.Tambo elsewhere in this page.
Simply change the values of the variables at the top to change the size of the "X".
Credit for the solution itself goes to Gildas. All I've done is given it adaptable math.
:root {
/* Width and height of the box containing the "X" */
--BUTTON_W: 40px;
/* This is the length of either of the 2 lines which form the "X", as a
percentage of the width of the button. */
--CLOSE_X_W: 95%;
/* Thickness of the lines of the "X" */
--CLOSE_X_THICKNESS: 4px;
}
body{
background:blue;
}
div{
width: var(--BUTTON_W);
height: var(--BUTTON_W);
background-color:red;
position: relative;
border-radius: 6px;
box-shadow: 2px 2px 4px 0 white;
}
/* The "X" in the button. "before" and "after" each represent one of the two lines of the "X" */
div:before,div:after{
content: '';
position: absolute;
width: var(--CLOSE_X_W);
height: var(--CLOSE_X_THICKNESS);
background-color:white;
border-radius: 2px;
top: calc(50% - var(--CLOSE_X_THICKNESS) / 2);
box-shadow: 0 0 2px 0 #ccc;
}
/* One line of the "X" */
div:before{
-webkit-transform:rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
left: calc((100% - var(--CLOSE_X_W)) / 2);
}
/* The other line of the "X" */
div:after{
-webkit-transform:rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
right: calc((100% - var(--CLOSE_X_W)) / 2);
}
<div></div>

Check & and Cross:
<span class='act-html-check'></span>
<span class='act-html-cross'><span class='act-html-cross'></span></span>
<style type="text/css">
span.act-html-check {
display: inline-block;
width: 12px;
height: 18px;
border: solid limegreen;
border-width: 0 5px 5px 0;
transform: rotate( 45deg);
}
span.act-html-cross {
display: inline-block;
width: 10px;
height: 10px;
border: solid red;
border-width: 0 5px 5px 0;
transform: rotate( 45deg);
position: relative;
}
span.act-html-cross > span { {
transform: rotate( -180deg);
position: absolute;
left: 9px;
top: 9px;
}
</style>

Related

how to make an illusion of 3D image

I have image and I want to make it look like 3D. It should be looking like this:
How can I do this? I tried box-shadow but it didn't look like real 3d.
border with gradient can do it:
img {
border-style: solid;
border-width: 0px 15px 15px 0px;
border-image-slice: 0 15 15 0; /* same as border-width*/
border-image-source: linear-gradient(45deg, transparent 10px, grey 0 calc(100% - 10px), transparent 0);
}
body {
background: pink;
}
<img src="https://picsum.photos/id/1069/300/200">
like below if you want different coloration for a better 3D rendring:
img {
--t:15px;
border-right: var(--t) solid grey;
border-bottom:var(--t) solid #626161;
clip-path:polygon(0 0,calc(100% - var(--t)) 0,100% var(--t),100% 100%,var(--t) 100%,0 calc(100% - var(--t)));
}
body {
background: pink;
}
<img src="https://picsum.photos/id/1069/300/200">
This is yet another approach: use before and after pseudo-elements with transform.
.whatever
{
display: block;
width: 100px;
height: 100px;
background: url("https://picsum.photos/100/100");
}
.whatever::before
{
content:"";
background-color: gray;
position:relative;
display: block;
transform: skewX(45deg);
top: 100px;
left: 5px;
width: 100px;
height: 10px;
}
.whatever::after
{
content:"";
background-color: gray;
position:relative;
display: block;
transform: skewY(45deg);
left: 100px;
top: -4px;
width: 10px;
height: 100px;
}
<div class="whatever"></div>

Adding depth to a box CSS

I am trying to add sides to a box div with CSS but can't seem to figure it out. This is what I have so far. Can anyone point me in the right direction? I have included below the picture I am trying to replicate. It is the middle box.
body {
background: #1b1b1b;
color: white;
}
.container {
display: table;
margin: auto;
}
.box {
width: 150px;
height: 150px;
background: #cc0000;
margin: 50px;
}
.right-skew {
position: relative;
}
.right-skew:before {
z-index: -1;
content: '';
position: absolute;
top: 0;
bottom: 0;
right: -15px;
display: block;
width: 35px;
background: grey;
-webkit-transform: skew(-10deg);
-ms-transform: skew(-10deg);
transform: skew(-10deg);
}
.right-skew:after {
z-index: -1;
content: '';
position: absolute;
top: 0;
bottom: 0;
right: -15px;
display: block;
width: 35px;
background: grey;
-webkit-transform: skew(10deg);
-ms-transform: skew(10deg);
transform: skew(10deg);
}
.skew-border {
border: 5px solid yellow;
}
<div class="container">
<div class="box right-skew"></div>
</div>
You can accomplish this with borders pretty easily.
I'd put a large border around the left and right boxes and only color and left and right borders inversely.
* {
box-sizing: border-box;
}
.boxes {
display: flex;
justify-content: center;
}
.box {
width: 30%;
height: 200px;
text-align: center;
}
.box--1,
.box--3 {
border: 20px solid white;
background-color: rgb(200, 0, 0);
}
.box--1 {
border-right-color: red;
}
.box--3 {
border-left-color: red;
}
.box--2 {
background-color: darkred;
}
<div class="boxes">
<div class="box box--1">1</div>
<div class="box box--2">2</div>
<div class="box box--3">3</div>
</div>
Here's a quick demo: https://jsfiddle.net/15k214am/3/
Some fun with transitions cause I'm bored: https://jsfiddle.net/15k214am/4/
Here's a small adjustment to allow the background color to show through: https://jsfiddle.net/15k214am/5/
On either side, you need to add a couple of pseudo elements that are rotated with perspective added to the rotation transform.
body {
background: #1b1b1b;
color: white;
}
.container {
display: table;
margin: auto;
}
.box {
width: 150px;
height: 150px;
background: #cc0000;
margin: 50px;
}
/* following lines were added/modified */
.with-depth {
position: relative;
}
.with-depth:before, .with-depth:after {
content: '';
position: absolute;
top: 0px; /* no need to change */
height: 100%; /* no need to change */
width: 25px; /* can be changed depending on the required width */
background: grey;
z-index: -1; /* not really needed but will stop it from interfering with interation */
}
.with-depth:before {
right: -25px; /* equal to -1 * width of pseudo-element */
transform-origin: left; /* don't change */
transform: perspective(10px) rotateY(10deg); /* can be changed as per need */
}
.with-depth:after {
left: -25px; /* equal to -1 * width of pseudo-element */
transform-origin: right; /* don't change */
transform: perspective(10px) rotateY(-10deg); /* can be changed as per need */
}
/* just for demo */
.box:hover{
height: 250px;
width: 250px;
}
<div class="container">
<div class="box with-depth"></div>
</div>
Using this method would:
produce a responsive output (try hovering the element in the demo) unlike the output that would be produced through the border method (was referring to adding borders with pseudo-element on the middle one and not borders on the side elements like the other answer, which is very good).
leave the portion above and below the side elements transparent just in case the need is to show the background.
let you have greater control over the angle of the depth.
make it a little more easier to add extra effects like shadows etc to the box. Refer demo below. (This point is not applicable for shape shown in question but would be useful for a generic one.)
.box {
width: 150px;
height: 150px;
background: #cc0000;
margin: auto;
box-shadow: 0px 2px 4px 2px #CCC;
}
.with-depth {
position: relative;
}
.with-depth:before,
.with-depth:after {
content: '';
position: absolute;
top: 0px;
height: 100%;
width: 25px;
background: grey;
}
.with-depth:before {
right: -25px;
transform-origin: left;
transform: perspective(10px) rotateY(10deg);
box-shadow: 4px 4px 4px 2px #CCC;
}
.with-depth:after {
left: -25px;
transform-origin: right;
transform: perspective(10px) rotateY(-10deg);
box-shadow: -4px 4px 4px 2px #CCC;
}
/* just for demo */
.box:hover {
height: 250px;
width: 250px;
}
<div class="box with-depth"></div>

Rounding a corner that's already been affected by a border-radius [duplicate]

I'm having a slight problem with css. I need a trapezoid div which upper left corner(the one with the angle above 90 degrees) is rounded. I already know that this:
HTML:
<div style="margin:30px">
<div class="trapezoid">
</div>
</div>
CSS:
.trapezoid{
vertical-align: middle;
border-bottom: 31px solid red;
border-left: 25px solid transparent;
height: 0;
width: 150px;
}
produces a trapezoid. I tried the border-top-left-radius property, however the effect is not sufficent enough.
Here's a jsfiddle with the above code to, well, fiddle with: http://jsfiddle.net/n3TLP/5/
I there is more info needed just comment.
Thanks in advance :)
Not that you should ever do this, but you can also create a rounded corner trapezoid with a single element by applying CSS 3d transformations:
.trapezoid {
position: relative;
width: 300px;
height: 200px;
overflow: hidden;
}
.trapezoid:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 200%;
height: 100%;
background: red;
border-radius: 20px 0 0 0;
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
-webkit-transform: perspective(400px) rotateX(45deg);
-moz-transform: perspective(400px) rotateX(45deg);
-ms-transform: perspective(400px) rotateX(45deg);
-o-transform: perspective(400px) rotateX(45deg);
transform: perspective(400px) rotateX(45deg);
}
​
http://jsfiddle.net/RzJTP/
Although I think you're better off using <canvas>/SVG to draw this shape, this is close to what you want:
.trapezoid{
vertical-align: middle;
border-bottom: 120px solid red;
border-left: 200px solid transparent;
border-top-left-radius:30px;
height: 0;
width: 150px;}
/* ---------- */
.trapezoid {
position:relative;
}
.trapezoid:after {
content:' ';
left:-14px;
top:-10px;
position:absolute;
background:red;
border-radius:40px 0 0 0;
width:164px;
height:40px;
display:block;
}
Demo: http://jsfiddle.net/n3TLP/20/
It's not perfect, and you'll have to play with the numbers to get your desired dimensions, it's very finicky. You might be interested in something like Raphaël for drawing, CSS doesn't really have the capacity for complex shapes (at least not intentionally).
Voila:
css:
.trapezoid{
vertical-align: middle;
background: red;
padding-left: 200px;
height: 120px;
width: 150px;
position: relative;
border-top-left-radius: 40px;
overflow: hidden;
background-clip: content-box;
}
.trapezoid:after{
content: '';
margin-left: -100px;
top: 0;
height: 120px;
background: red;
transform: skew(-31deg,0deg);
-o-transform: skew(-31deg,0deg);
-ms-transform: skew(-31deg,0deg);
-moz-transform: skew(-31deg,0deg);
-webkit-transform: skew(-59deg,0deg);
position: absolute;
width: 1000px;
border-top-left-radius: 40px;
}
Demo:
http://jsfiddle.net/n3TLP/24/
Here's my attempt lol
.trapezoid{
position:relative;
border-bottom: 100px solid blue;
border-right: 12px solid transparent;
border-left: 180px solid transparent;
width: 122px;
}
.trapezoid:before{
content:' ';
left:-184px;
top:98px;
position:absolute;
background:blue;
border-radius:80px 20px 80px 80px;
width:318px;
height:20px;
}
.trapezoid:after {
content:' ';
left:-11px;
top:-7px;
position:absolute;
background:blue;
border-radius:150px 50px 90px 0px;
width:133px;
height:30px;
}
<div style="margin:30px">
<div class="trapezoid">
</div>
</div>
http://jsfiddle.net/Bzj3h/
Use Adobe Illustrator or any other software to draw a shape and than save it as SVG code, you can use SVG directly on the page but IE8 and lower will ignore it. If you need to support older versions of IE you can use Raphael.js to draw your SVG element.
Rendering SVG polygons in Raphael Javascript library

CSS trapezoid shape clickable area issue in chrome browser

I'm trying to get a trapezoidal perspective shape to have the whole area be clickable. I've gotten it to work in Firefox and even IE, but Chrome isn't cooperating too well.
Here's a fiddle with the shape and a link: http://jsfiddle.net/9n9uh6f6/1/
As you can tell, the link doesn't become active until you hover over the 'area' part of the text. In other browsers, the whole height of the shape is clickable.
I read that Chrome renders a perspective image differently and perhaps that's why it's not doing what it's supposed to.
Here's my CSS:
.prodcaptions {
width:136px;
height: 85px;
position:relative;
left:10%;
text-transform:uppercase;
text-align:center;
letter-spacing: 1.6px;
color: #000;
}
.prodcaptions:before {
content:"";
position:absolute;
border-radius:1px;
box-shadow:0 0 0 3px #27628e;
top:-5%;
bottom:-11%;
left:-1%;
right:-5%;
-webkit-transform:perspective(40em) rotateX(-45deg);
transform:perspective(40em) rotateX(-45deg);
}
.prodcaptions a {
z-index:999;
position:relative;
height: 85px;
display: block;
padding-top: 25px;
}
Please have look at this code:
.prodcaptions {
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding: 10px;
perspective: 150px;
perspective-origin: 50% 0;
}
a{
padding: 50px;
position: absolute;
border: 1px solid black;
transform: rotateX(-15deg);
}
Seems to work the way you want it. fiddle
Try this shape for link trapazoid shape - jsFiddle
Advantage - you can change skew property to change angle of shape! Easy and effective! Reverse value for reverse shape!
html
Click Here!
css
a {
display: block;
z-index: 1;
position: relative;
/* custom sizes */
width: 136px;
height: 85px;
/* demo-only decoration */
margin: 100px auto;
font: 16px/50px Arial, sans-serif;
text-transform: uppercase;
text-align: center;
background-color: orange;
}
a:before, a:after {
content:'';
position: absolute;
top: 0;
left: 0;
width: 100%;
bottom: 0;
z-index: -1;
/* demo-only decoration */
border-radius: 4px;
background-color: orange;
}
a:before {
transform: skew(-20deg);
left: 25px;
}
a:after {
transform: skew(20deg);
right: 25px;
left: auto;
}

How to design below effect in a div without using any Images

How can we design tip in bottom just like above without using any images.
Below is my trail code:
<div id="coverImageToolTip"><p><font color="white">TIP:</font> UPLOAD YOUR<br/> COVER IMAGE HERE
<div id="tail1"></div>
<div id="tail2"></div>
#coverImageToolTip {
position: absolute;
z-index: 10;
padding: 0px 4px;
background-color: gray;
bottom: 100px;
left: 20%;
border-radius: 10px;
font-weight: bold;
border-bottom: 5px solid black;
}
/* #tail1 {
position:absolute;
bottom:100px;
left:20px;
width:0;height:0;
border-color:#a0c7ff transparent transparent transparent;
border-width:10px;
border-style:solid;
} */
#tail2 {
position:absolute;
bottom:-18px;
left:20px;
width:0;height:0;
border-color: red transparent transparent red ;
border-width:10px;
border-style:solid;
transform:rotate(90deg);
-ms-transform:rotate(90deg); /* IE 9 */
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
}
A minimal markup version:
DEMO
HTML:
<div class='tooltip'>
<span class='highlight'>tip:</span> upload your cover image here
<div>
Relevant CSS:
.tooltip {
position: relative;
margin: 1em auto;
padding: .5em .2em;
width: 10.5em; height: 3em;
border-radius: .25em;
box-shadow: 0 .2em 0 black;
background: #999;
font: 700 1.6em/1.5 sans-serif;
}
.tooltip:before {
position: absolute;
top: -.75em; right: -.75em;
border: solid .2em;
width: 1.5em; height: 1.5em;
border-radius: 50%;
background: black;
color: #999;
font: 900 .65em/1.5 sans-serif;
content: 'x';
}
.tooltip:after {
position: absolute;
z-index: -1;
right: 25%; bottom: -.75em;
width: 2em; height: 2em;
box-shadow: 0 .35em 0 black;
transform: rotate(30deg) skewY(-60deg);
background: inherit;
content: '';
}
.highlight:after, .highlight:before {
position: absolute;
top: 100%; right: 31.025%;
width: 1.725em; height: .2em;
transform: skewX(-30deg);
background: #999;
content: '';
}
.highlight:after {
right: 30.65%;
transform: skewX(-60deg);
}
please see Pure css close button ( the close button in CSS ) and http://v2.desandro.com/resources/css-speech-bubble-icon/ for the actual trail.
You can do the close button and arrow in css but shadow for arrow is not possible.
Look at the code below
HTML
<div id="coverImageToolTip">
<div class="close">X</div>
<p>
<font color="white">TIP:</font> UPLOAD YOUR<br/> COVER IMAGE HERE
</p>
<div id="tail1"></div>
<div id="tail2"></div>
</div>
CSS
.close a{
position:absolute;
right:-5px; top:-8px;
display:inline-block;
background:black;
padding:2px 6px;
color:white;
border:solid grey 3px;
border-radius:22px;
font-size:12px;
text-decoration:none
}
#tail2 {
position:absolute;
bottom:-19px;
left:80px;
width:0;height:0;
border-color: grey transparent transparent grey ;
border-width:10px;
border-style:solid;
transform:rotate(90deg);
-ms-transform:rotate(90deg); /* IE 9 */
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(1deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
}
DEMO
You can use before and after to simulate a shape close to your image for the arrow. Have a look at this demo: http://jsfiddle.net/j34um/3/