🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #156

Hover Effects


This page covers CSS button hover effects, shadows, disabled states, and width.


CSS Hoverable Buttons

The CSS :hover pseudo-class is used to change the style of a button when you mouse over it.

Tip: Use the CSS transition-duration property to determine the speed of the "hover" effect:

Example

.button {
  transition-duration: 0.4s;
}

.button:hover {

background-color: #4CAF50; /* Green */
  color: white;
}

CSS Buttons With Shadow

The CSS box-shadow property is used to add a shadow to a button:

Example

  .button1 {box-shadow:0 8px 16px 0 rgba(0,0,0,0.6)}
.button2:hover
  {box-shadow:0 8px 16px 0 rgba(0,0,0,0.6)}

CSS Disabled Button

The CSS opacity property can be used to add transparency to a button (creates a "disabled" look).

Tip: You can also add the cursor property with a value of "not-allowed", which will display a "no parking sign" when you mouse over the button:

Example

.disabledbtn {
  opacity: 0.6;
  cursor: not-allowed;
}

CSS Button Width

By default, the size of a button is determined by its text content.

The CSS width property can be used to define a specific width for a button.

Tip: Use pixels to set a fixed width, or percent for a responsive width (e.g. 50% of its parent element).

Example

.button1 {width: 250px;}
.button2 {width: 50%;}
.button3 {width:
100%;}

Button on Image

Snow

Want to go beyond the notes?

Join CodingNow 2.0's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Hover Effects – FAQs

Quick answers about learning Hover Effects in CSS.

This free note from CodingNow 2.0 explains Hover Effects in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including Hover Effects, is 100% free with no signup required.
With focused practice, most students grasp Hover Effects in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now