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

Vue implements a simple calculator

This article example shares the specific code of ...

Detailed explanation of the working principle and solution of Js modularization

Table of contents 1. Modular concept 2. Modulariz...

15 JavaScript functions worth collecting

Table of contents 1. Reverse the numbers 2. Get t...

SQL left join and right join principle and example analysis

There are two tables, and the records in table A ...

The implementation of Youda's new petite-vue

Table of contents Preface Introduction Live Easy ...

Two query methods when the MySQL query field type is json

The table structure is as follows: id varchar(32)...

Notes on matching MySql 8.0 and corresponding driver packages

MySql 8.0 corresponding driver package matching A...

Detailed explanation of how to implement secondary cache with MySQL and Redis

Redis Introduction Redis is completely open sourc...

Vue dynamic menu, dynamic route loading and refresh pitfalls

Table of contents need: Ideas: lesson: Share the ...

How to build a virtual machine with vagrant+virtualBox

1. Introduction Vagrant is a tool for building an...

IIS 7.5 uses URL Rewrite module to achieve web page redirection

We all know that Apache can easily set rewrites f...