0% found this document useful (0 votes)
38 views7 pages

How To Add A Button To An Image

This document provides a tutorial on how to add a button over an image using HTML and CSS. It includes step-by-step instructions for creating a container, making the image responsive, and styling the button to position it in the center of the image. The tutorial also features example code snippets for both HTML and CSS.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views7 pages

How To Add A Button To An Image

This document provides a tutorial on how to add a button over an image using HTML and CSS. It includes step-by-step instructions for creating a container, making the image responsive, and styling the button to position it in the center of the image. The tutorial also features example code snippets for both HTML and CSS.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.

asp

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

How TO - Button on Image


❮ Previous Next ❯

Learn how to add a button to an image with CSS.

Button on Image

Button

Try it Yourself »

How To Add Button over Image


Step 1) Add HTML:

Example

1 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

<div<imgclass="container">
Tutorials  Exercises  Services 
src="img_snow.jpg" alt="Snow">
 Sign Up Log in

<button class="btn">Button</button>
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
</div>

ADVERTISEMENT

Step 2) Add CSS:

Example

/* Container needed to position the button. Adjust the width as needed */


.container {
position: relative;
width: 50%;
}

/* Make the image responsive */


.container img {
width: 100%;
height: auto;
}

/* Style the button and place it in the middle of the container/image */


.container .btn {

2 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

position: absolute;
 top:Tutorials
50%;  Exercises  Services   Sign Up Log in
left: 50%;
HTML
 CSS
transform:JAVASCRIPT SQL-50%);
translate(-50%, PYTHON JAVA PHP HOW TO W3.CSS C
-ms-transform: translate(-50%, -50%);
background-color: #555;
color: white;
font-size: 16px;
padding: 12px 24px;
border: none;
cursor: pointer;
border-radius: 5px;
}

.container .btn:hover {
background-color: black;
}

Try it Yourself »

❮ Previous Next ❯

W3schools Pathfinder
Track your progress - it's free! Sign Up Log in

ADVERTISEMENT

3 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

4 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

 Tutorials  Exercises  COLOR


Services PICKER  Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

 
ADVERTISEMENT

5 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

 Tutorials 
ADVERTISEMENT
Exercises  Services  
ADVERTISEMENT
Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

 PLUS SPACES GET CERTIFIED

FOR TEACHERS FOR BUSINESS CONTACT US

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference

6 of 7 30-Aug-24, 4:48 PM
How To Add a Button to an Image https://www.w3schools.com/howto/howto_css_button_on_image.asp

Bootstrap Reference

 PHP Reference
Tutorials 
HTML Colors
Exercises  Services   Sign Up Log in
Java Reference
HTML
 CSS Angular Reference
JAVASCRIPT
     SQL PYTHON JAVA PHP HOW TO W3.CSS C
jQuery Reference

Top Examples Get Certified


FORUM ABOUT ACADEMY
HTML Examples HTML Certificate
W3Schools
CSS Examplesis optimized for learning and training.
CSS Examples
Certificate might be simplified to
improve reading
JavaScript Examplesand learning. JavaScript Certificate
Tutorials, references, and examples are constantly
How To Examples Frontreviewed to avoid errors, but we
End Certificate
cannot
SQL warrant full correctness
Examples SQL Certificate
of all content.
Python ExamplesWhile using W3Schools, you agree to have
Python read and accepted our
Certificate
terms of use,
W3.CSS Examples cookie and privacy policy. PHP Certificate
Bootstrap Examples jQuery Certificate
Copyright
PHP Examples1999-2024 by Refsnes Data. All Rights
JavaReserved.
Certificate W3Schools is Powered by
W3.CSS.
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

7 of 7 30-Aug-24, 4:48 PM

You might also like