Arrow Shaped Button using HTML and CSS

Arrow Shaped Button using HTML and CSS
Code Snippet:CSS3 Arrow Buttons
Author: Simon Albrecht
Published: January 19, 2024
Last Updated: January 22, 2024
Downloads: 3,496
License: MIT
Edit Code online: View on CodePen
Read More

This code creates an Arrow Shaped Button using HTML and CSS. It uses CSS to style buttons with arrow shapes for “Previous” and “Next” navigation. The buttons change color on hover, providing a simple and attractive interface for navigation.

You can use this code on your website for navigational buttons or pagination projects. Moreover, you can customize the buttons with additional CSS according to your website’s design.

How to Create Arrow Shaped Button Using HTML and CSS

1. Begin by setting up the HTML structure for your arrow buttons. In your HTML file, create a div to contain your buttons and use anchor tags to define the “Previous” and “Next” buttons. Give them appropriate class names for styling, like “button prev” and “button next.”

<div class="button-bar">
  <a href="#" class="button prev">Previous</a>
  <a href="#" class="button next">Next</a>
</div>

2. Now, let’s add the CSS code to style your arrow buttons. We have divided the CSS into sections for clarity, including general styles, button bar styles, and button styles. Adjust the styles to match your website’s design.

/* LESS Variables */
/* -------------- */
/* General */
/* Button Bar */
/* Button */
/* Elements */
/* -------- */

/* Layout */
/* ------ */
h1.welcome,
.button-bar {
  margin: 20px auto;
  height: auto;
}
.button-bar {
  background: #ededed;
  padding: 40px;
}
/* General Button */
/* -------------- */
.button {
  position: relative;
  margin: 0;
  padding-left: 14px;
  padding-right: 14px;
  padding-top: 2.8px;
  padding-bottom: 2.8px;
  background: #0d5287;
  color: white;
  font-size: 14px;
}
.button::after {
  content: '';
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
}
.button:hover {
  background: #0585e8;
}
/* Arrow Buttons */
/* ------------- */
.next::after,
.prev::after {
  border-style: solid;
}
/* Next Button */
/* ----------- */
.next::after {
  right: -22px;
  border-width: 11px;
  border-color: transparent transparent transparent #0d5287;
}
.next:hover::after {
  border-left-color: #0585e8;
}
/* Prev Button */
/* ----------- */
.prev::after {
  left: -22px;
  border-color: transparent #0d5287 transparent transparent;
  border-width: 11px;
}
.prev:hover::after {
  border-right-color: #0585e8;
}

The key to creating arrow buttons is adding arrow shapes to the “Next” and “Previous” buttons. We do this by using CSS pseudo-elements (::after) and border properties. The “Next” button’s arrow points to the right, and the “Previous” button’s arrow points to the left. Customize the colors and sizes as needed.

That’s all! hopefully, you have successfully created an Arrow Shaped Button Using HTML and CSS. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X