Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw an X in CSS

I've got a div that looks like a orange square

enter image description here

I'd like to draw a white X in this div somehow so that it looks more like

enter image description here

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; } 
like image 462
natsuki_2002 Avatar asked Sep 20 '13 15:09

natsuki_2002


People also ask

Can you draw lines in CSS?

Its simple to add a horizontal line in your markup, just add: <hr>. Browsers draw a line across the entire width of the container, which can be the entire body or a child element.

What is :: after in CSS?

::after (:after) In CSS, ::after creates a pseudo-element that is the last child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.

How do you make a diagonal line in CSS?

From a CSS point of view, a diagonal line is nothing but a horizontal line which is rotated at +45 or -45 degrees angle. So, to draw a diagonal line in CSS, we have to simply rotate a normal horizontal line at an angle of + or – 45 degrees. The rotation in CSS is done using the transform property.


1 Answers

You want an entity known as a cross mark:

http://www.fileformat.info/info/unicode/char/274c/index.htm

The code for it is &#10060; and it displays like ❌

If you want a perfectly centered cross mark, like this:

cross mark demo

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, &#xd7; which displays as ×.

like image 174
Marc Audet Avatar answered Sep 21 '22 09:09

Marc Audet