Home > Web Front-end > CSS Tutorial > Use css to achieve a simple check mark effect

Use css to achieve a simple check mark effect

王林
Release: 2020-12-31 09:50:17
forward
2673 people have browsed it

Use css to achieve a simple check mark effect

Generally we have two ideas to implement it, one is to insert ready-made symbols into the page, and the other is to use css to implement it.

(Learning video sharing: css video tutorial)

This article mainly introduces the second idea:

  • To the block level Set the width and height of the element

  • Set the two adjacent borders of the element

  • Rotate the element

HTML

<div class="check-style-unequal-width"></div>
Copy after login

Analysis:

  • You need to use block-level elements here

  • No need to set element content

CSS

.check-style-unequal-width {
 
    width: 8px;
 
    height: 16px;
 
    border-color: #009933;
 
    border-style: solid;
 
    border-width: 0 3px 5px 0;
 
    transform: rotate(45deg);
 
}
Copy after login

Analysis:

  • Set the width and height to get a rectangular effect, and there is no content in the rectangle

  • Set the style of the adjacent border and get the general outline of the check mark

  • Use the rotation attribute to successfully get the check mark

Running effect

Use css to achieve a simple check mark effect

Analysis:

As shown in the picture above, the first one is a check mark effect with two lines of equal width, and the second one is The checkmark effect of two lines with unequal width; the third one is the checkmark effect of two lines of equal width and length.

Note:

  • It is useless to directly set the width and height of row-level elements. You need to set its display to make it a block-level element. For example: span needs to set the display to inline-block to be applicable to this example

  • You can adjust the element width and height according to actual needs

  • Yes Set different borders according to actual needs, as well as the width of adjacent borders

  • You can make simple modifications to this effect, which applies to pseudo elements::before and ::after. You can refer to ::before & ::after

##Related recommendations:

CSS tutorial

The above is the detailed content of Use css to achieve a simple check mark effect. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template