How to use css to implement triangle symbols (with code)

云罗郡主
Release: 2018-10-10 09:25:43
forward
2771 people have browsed it

The content of this article is about how to use css to implement triangle symbols. The code has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

The picture below is an element with a length and width of 100px and a border width of 100px. It can be seen that the intersection of the upper, lower, left and right borders in CSS is not a straight line, so it can be written according to this attribute Triangle symbol

So how to use this property of css to achieve the effect of triangle symbol? The code is as follows:

html code

<body>
    <p></p></body>
Copy after login

css code

p:after{
    position: absolute;
    width: 0px;
    height: 0px;
    content: " ";
    border-right: 100px solid transparent;
    border-top: 100px solid #ff0;
    border-left: 100px solid transparent;
    border-bottom: 100px solid transparent;
}
Copy after login

Rendering:

This method is to use pseudo-classes to implement triangle symbols, and then use absolute positioning, which will not take up space

transparent is a transparent color, if you want a triangle The directions of the symbols are different. Just add the border color in the corresponding direction and change the others to transparent colors.

The above is a complete introduction to how to use css to realize the triangle symbol (with code) , the content of this article is compact, I hope everyone can gain something, please pay attention to the PHP Chinese website for more.

The above is the detailed content of How to use css to implement triangle symbols (with code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!