HTML+CSS implements a beautiful triangle prompt box style

yulia
Release: 2018-10-18 17:42:17
Original
4933 people have browsed it

When browsing the website, have you ever noticed that there are all kinds of novel prompt boxes on the website? Do you know how to make these beautiful prompt boxes? This article will share with you a beautiful triangle prompt box implemented in CSS. It has certain reference value. Interested friends can refer to it.

If you want to use CSS to implement the triangle prompt box style, you need to use many attributes in CSS, such as: display attribute, border-radius fillet, position positioning, etc. If you are unclear, you can take a look. My previous articles have been introduced before, or visit CSS Video Tutorial.

Instance description: Give a div, use border-radius, before, border-top and other attributes, add triangles to the upper left corner and lower right corner of the prompt box, and create a triangle prompt box. The specific code is as follows:

HTML part:

<div class="main">
   <p>这是内容这是内容这是内容这是内容这是内容这是内容</p>
</div>
Copy after login

CSS part:

*{
      margin: 0;
      padding: 0;
     }  
     .main{
      width: 120px;
      display: inline-block;
      font-size: 14px;
      color: #333;
      line-height: 28px;
      background: #F0981C;
      position: relative;
      padding: 10px;
      -webkit-border-radius:5px;
      -moz-border-radius:5px;
      : 5px;
     }
     /*左三角*/
     .main:before{
      content: &#39; &#39;;
      border-top: 8px solid transparent;
      border-bottom: 8px solid transparent;
      border-right: 12px solid #F0981C;
      position: absolute;
      top: 15px;
      left: -12px;
     }
     /*右三角*/
     .main:after{
      content: &#39; &#39;;
      border-top: 8px solid transparent;
      border-bottom: 8px solid transparent;
      border-left: 12px solid #F0981C;
      position: absolute;
      bottom: 15px;
      right: -12px;
     }
Copy after login

Rendering:

HTML+CSS implements a beautiful triangle prompt box style

##The above shared tips for making triangles with CSS Friends who like the code of the box can use it or modify it to their favorite style. I hope this article will be helpful to you!

【Recommended related tutorials】

1.

HTML video tutorial2.
CSS3 video tutorial3.
bootstrap tutorial

The above is the detailed content of HTML+CSS implements a beautiful triangle prompt box style. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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