Sample code for achieving small triangle border effect with pure CSS3+DIV

Sample code for achieving small triangle border effect with pure CSS3+DIV

The specific code is as follows:

The html code is as follows <div class="arrow-up">
     <!--Upward triangle-->
</div>
<div class="arrow-down">
    <!--Downward triangle-->
</div>
<div class="arrow-left">
    <!--Left-pointing triangle-->
</div>
<div class="arrow-right">
    <!--Rightward triangle-->
</div>
 
Below we use CSS3 to implement the upward, downward, left and right triangles respectively /*arrow up*/
.arrow-up {
    width:0;
    height:0;
    border-left:30px solid transparent;
    border-right:30px solid transparent;
    border-bottom:30px solid #fff;
}
    
 /*arrow down*/
.arrow-down {
    width:0;
    height:0;
    border-left:20px solid transparent;
    border-right:20px solid transparent;
    border-top:20px solid #0066cc;
}
    
 /*Arrow pointing left*/
.arrow-left {
    width:0;
    height:0;
    border-top:30px solid transparent;
    border-bottom:30px solid transparent;
    border-right:30px solid yellow;
}
   
/*arrow right*/
.arrow-right {
    width:0;
    height:0;
    border-top:50px solid transparent;
    border-bottom: 50px solid transparent;
    border-left: 50px solid green;
}

Mini Program Example

wxml

<view class="index_sale_lists">
      <view class="sanjiao"></view>
      <view class="index_sale_list">
        <view class="index_sale_choice">You have chosen: <text>Shangnao</text></view>
        <view class="index_sale_tezhi">
          <text>
            Characteristics: Beef topside is located at the back of the shoulder and neck, on both sides of the spine. The meat is tender and juicy, the fat is evenly distributed, and it has beautiful marble patterns. It has a soft texture and melts in the mouth. It is low in fat and high in protein. It is suitable for hot pot, and can be fried, deep-fried and grilled.
          </text>
        </view>
      </view>
    </view>

wxss

.index_sale_lists{
  margin: 50rpx 24rpx 0;
  background-color: #F2F6F4;
  border-radius: 20rpx;
  position: relative;
}
.sanjiao{
    position: absolute;
    left: 50%;
    top:-15rpx;
    width:0;
    height:0;
    border-left:10px solid transparent;
    border-right:10px solid transparent;
    border-bottom:10px solid #F2F6F4;
    /* z-index: -1; */
}

Summarize

This is the end of this article about how to use pure CSS3+DIV to achieve a small triangular border. For more relevant CSS div content about achieving a triangular border, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  Summary of the top ten problems of MySQL index failure

>>:  Div covers the flash. Flash transparent method realizes placing the DIV layer on the flash.

Recommend

How to reference jQuery in a web page

It can be referenced through CDN (Content Delivery...

Summary of four ways to loop through an array in JS

This article compares and summarizes four ways of...

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

How does JS understand data URLs?

Table of contents Overview Getting started with d...

MYSQL performance analyzer EXPLAIN usage example analysis

This article uses an example to illustrate the us...

Detailed tutorial on running multiple Springboot with Docker

Docker runs multiple Springboot First: Port mappi...

javascript to switch pictures by clicking a button

This article example shares the specific code of ...

How to use the jquery editor plugin tinyMCE

Modify the simplified file size and download the ...

Detailed troubleshooting of docker.service startup errors

Execute the following command to report an error ...

React Hooks Usage Examples

Table of contents A simple component example More...

The difference between Display, Visibility, Opacity, rgba and z-index: -1 in CSS

We often need to control the hidden, transparent ...

Detailed summary of mysql sql statements to create tables

mysql create table sql statement Common SQL state...