Code for implementing simple arrow icon using div+CSS in HTML

Code for implementing simple arrow icon using div+CSS in HTML

In web design, we often use arrows as decoration to embellish our web pages. Although many website designers now like to use font icons to achieve the effect of arrows, that will also have some impact on the loading of the web page. Today, the editor of Feiniao Muyu will tell you how to use div and CSS to achieve some arrow effects in web design.

DIV+CSS to achieve the effect of a solid small arrow

In some secondary navigation menus on web pages, or lists with drop-down functions, there are some small arrows implemented to indicate that a DIV contains content. So how do we implement the style of these small arrows?

First, the CSS code

/*Arrow up*/
.to_top {
    width: 0;
    height: 0;
    border-bottom: 10px solid #ccc;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}
/*arrow down*/
.to_bottom {
    width: 0;
    height: 0;
    border-top: 10px solid #ccc;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}
/*Arrow pointing left*/
.to_left {
    width: 0;
    height: 0;
    border-right: 10px solid #ccc;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}
/*arrow right*/
    .to_right {
    width: 0;
    height: 0;
    border-left: 10px solid #cccf;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

HTML Code

<p>Up Arrow</p>
<div class="to_top"></div>
<p>Left Arrow</p>
<div class="to_left"></div>
<p>Right Arrow</p>
<div class="to_right"></div>
<p>Down Arrow</p>
<div class="to_bottom"></div>

Code running results

If you feel that the arrow is too big or too small, and the color is not what you want, we can adjust the size of the arrow by adjusting the thickness and color of the DIV border.

DIV+CSS to achieve the effect of large arrow

When I was modifying the three-column theme yesterday, a user gave me feedback that a large left and right arrow should be added. Although it is very simple to implement (you can use a background image instead), you need to add a background function that can customize the color, so I thought of using DIV+CSS to draw the arrow, so that you can easily customize the color of the arrow.

CSS Code

.text{
    display: inline-block;
    border-top: 2px solid;
    border-right: 2px solid;
    width: 100px;
    height: 100px;
    border-color: #EA6000;
    transform: rotate(-135deg);
    margin: 50px auto auto 100px;
}

HTML Code

<span class="text"></span>

Code running results

We can modify the arrow type by modifying the code below C, and we can also modify the width and height to change the size of the arrow.

transform: rotate(-135deg);/*Adjust the rotation angle*/

Summarize

The above is the code that I introduced to you in HTML using div+CSS to implement a simple arrow icon. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  Analysis of the underlying principle of MySQL multi-version concurrency control MVCC

>>:  Use render function to encapsulate highly scalable components

Recommend

Debian virtual machine created by VirtualBox shares files with Windows host

the term: 1. VM: Virtual Machine step: 1. Downloa...

iFrame is a great way to use it as a popup layer to cover the background

I have been working on a project recently - Budou ...

HTML Code Writing Guide

Common Convention Tags Self-closing tags, no need...

Teach you how to build Tencent Cloud Server (graphic tutorial)

This article was originally written by blogger We...

Detailed description of shallow copy and deep copy in js

Table of contents 1. js memory 2. Assignment 3. S...

jQuery implements all selection and reverse selection operation case

This article shares the specific code of jQuery t...

Vue implements tab label (label exceeds automatic scrolling)

When the created tab label exceeds the visible ar...

Implementation of Vue package size optimization (from 1.72M to 94K)

1. Background I recently made a website, uidea, w...

Implementation of Docker cross-host network (manual)

1. Introduction to Macvlan Before the emergence o...

Solution to the blank page after vue.js packaged project

I believe that many partners who have just come i...

Implementation of Vue large file upload and breakpoint resumable upload

Table of contents 2 solutions for file upload Bas...

Example code for css flex layout with automatic line wrapping

To create a flex container, simply add a display:...

How to make React components full screen

introduce This article is based on React + antd t...