CSS implements a digital label style

Source: Internet
Author: User

Everyone in the shopping site or the novel site will find that there is a product or novel cover map next to the rankings or popular signs, then we today to talk about how to achieve these signs of it!

CSS Implementation leaderboard Tag style


That
  

The following are the main steps to introduce my implementation process:

    • Initial implementation method (unsuccessful)

    • Subsequent implementation methods (success)

    • Original Web page Implementation method

1. Initial implementation method

The first thing to think about when you look at this style is that you should be able to implement it using CSS. The implementation is a fixed width and height of the red p, plus a white triangle below the lower part of the red P can be achieved. But at the end of the day it looks like this.
  
  

The problem with finding out here is that the triangles will obscure the images behind them and look strange. So the first thought of the solution is to adjust the z-index size to change the level, the first red P z-index must be greater than the z-index of the picture, then if the triangle can reveal the picture will not cover the red p. So it doesn't work.

2. Change of drawing

Since the above method is not possible, then you can find that if we do not draw the bottom of the white triangle, but the painting on both sides of the red triangle, in the reduction of the height of the red p, and then splicing a bit, then you can complete the above style, and can reveal the picture. In the CSS code, only the following changes need to be made

. trangle {border-left:15px Solid transparent;border-right:15px solid transparent;border-bottom:10px solid #fff;}

Switch

. trangle {border-left:15px Solid transparent;border-right:15px solid transparent;border-bottom:10px solid #fff;}


You can see that this will achieve the effect. Therefore, when using CSS to write such graphics, the method is mostly more than one, or should think more about the implementation method.

3. Original Web page implementation

Google F12 The original page, only to find that the original page of the leaderboard tag is a picture ah ...

Related recommendations:

CSS3 achieve bar percent effect

CSS3 The shadow of the detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.