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; }
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.
::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.
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.
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
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 ×.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With