An open-close button in CSS generally refers to a button used in web interfaces to toggle the visibility of a menu, panel, dialog, or other content. These buttons are commonly seen in responsive designs, especially for navigation menus in mobile views (often represented as a “hamburger” icon which transforms into a “‘X‘” icon).
In this post, I have shared a collection of 16+ CSS open close buttons, complete with their source code. This compilation showcases a variety of close animations and effects, offering diverse styles from simple toggles to intricate animations. Each button is uniquely designed to enhance user interaction, providing both functionality and aesthetic appeal to your web projects.
Open & Close Button CSS

Description
This Open Close Button example showcases a button with an interactive hover effect. Styled primarily with CSS, the button changes color, border, and undergoes a transformation upon hovering. The key CSS properties include transition: all 0.3s ease-out
, which smooths the transition effects, and transform: scale(0.8) rotateZ(90deg)
on hover, scaling down the button and rotating it.
Cross Close Button

Description
This Cross Close Button example features a button designed to look like a cross, typically used for closing interfaces. The button is created using CSS, specifically through the .inner:before
and .inner:after
pseudo-elements. These elements are styled with a height, width, and background color, and positioned absolutely within a parent div. They are initially rotated at 45 and -45 degrees to form a cross. On hover, the :hover
pseudo-class alters their rotation to 0 degrees and moves them vertically, creating a dynamic effect.
Menu Close Button Animation

Description
This example is to create a button with an interactive animation effect, showcasing how CSS and JavaScript can work together for dynamic UI elements.
- CSS for Button Spans: The spans inside the button are styled with properties like
width
,height
, andbackground-color
. They are positioned usingposition: absolute
and rotated usingtransform: rotate(45deg)
or similar values to create a cross shape. - JavaScript Click Event: A jQuery click event handler is attached to the button. This handler toggles a class on the button, which likely triggers the CSS transformations.
- CSS Transformations on Toggle: The toggled class modifies the CSS
transform
property of the spans, changing their rotation and position, thus altering the button’s appearance dynamically on click.
Open & Close Button With Animation

Smooth Hamburger Close Button

CSS Animated Open and Close Button

Html Close Button

Simple Pure CSS Close Button

Hamburger Menu Button to Close Button

Hamburger to Close Button

Open and Close Button With Animation

Interactive Animated Close Button

Close Button CSS Animation

Different Close Button Effects

Different Flipping Style Close Buttons

Animated Close Button CSS
