Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw error icon with css only,exactly like in the image

Im trying to do the following x icon, exactly the way it is in here:

enter image description here

So here is the html:

<div class='error-circle'>
    <div>X</div>
</div>

And here is the css:

.error-circle{
    width: 70px;
    height: 70px;
    background: #990000;
    border-radius: 100px;
    border: 4px solid white;
    color: white;
    font-size: 45px;
    font-weight: bold;
    padding-left: 17px;
}

It's close, but i really need the same result as the image (without the background), I think the X should not be the x character but two lines crossed one on the other, How should i achieve this result?

like image 206
totothegreat Avatar asked Dec 17 '14 13:12

totothegreat


People also ask

How can I display just a portion of an image in HTML CSS?

Wrap the image in a div The markup to set up CSS-only cropping is super basic. All you need to do is wrap the img tag in a div . The pug image is 750 pixels wide and 500 pixels high. Let's make it portrait-oriented by maintaining the 500 pixel height, but chopping the width in half to 375 pixels.

How do you put an icon over an image in CSS?

Assign the Positions This is the most important step. The first step to enclose the components along with the image as one element and assign the CSS property position: relative . And the icons we need to place on the image is assigned the property position: absolute . In this case, we are adding the class .

How do you add an icon style in CSS?

The simplest way to add an icon to your HTML page, is with an icon library, such as Font Awesome. Add the name of the specified icon class to any inline HTML element (like <i> or <span> ). All the icons in the icon libraries below, are scalable vectors that can be customized with CSS (size, color, shadow, etc.)

How do I hover an icon in CSS?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.


1 Answers

1) Remove padding

2) Change border-radius to 50%

3) Try a different font like verdana

FIDDLE

.error-circle {
  width: 70px;
  height: 70px;
  line-height: 70px;
  background: #990000;
  border-radius: 50%;
  border: 4px solid white;
  color: white;
  font-size: 45px;
  font-family: verdana;
  text-align: center;
}
<div class='error-circle'>
  <div>X</div>
</div>
like image 124
Danield Avatar answered Sep 18 '22 08:09

Danield