Reputation: 391
I am really confused about why this code doesn't work for styling a button. Does anyone have any idea why this isn't working??
.button2 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
<div class="smallButtons" style="clear: both;">
<button class="button2">ADD TO REGISTRY</button>
<button class="button2">ADD TO LIST</button>
<button class="button2">SHARE</button>
</div>
https://jsfiddle.net/865eg40w/#&togetherjs=6RiA5b06zJ
Upvotes: 0
Views: 143
Reputation: 1670
On your fiddle there are some extra spaces before .button2
class. Just remove that and you will be done.
Upvotes: 2
Reputation: 14312
The problem is with the white space in your css. I have copied your css & html below and also made a duplicate copy that is identical in every way except for 2 things:
.button22
(so we can test both classes in
the same snippet)Your CSS doesn't work, but my identical CSS except for the white space does - run the snippet and you'll see both rows of buttons.
.button2 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
.button22 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
<div class="smallButtons" style="clear: both;">
<button class="button2">ADD TO REGISTRY</button>
<button class="button2">ADD TO LIST</button>
<button class="button2">SHARE</button>
</div>
<div class="smallButtons" style="clear: both;">
<button class="button22">ADD TO REGISTRY</button>
<button class="button22">ADD TO LIST</button>
<button class="button22">SHARE</button>
</div>
As to why the whitespace in yours is breaking it, I can't answer, but I can tell you that replacing it will solve the problem!
Upvotes: 2
Reputation: 2879
.button2 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
<button class="button2">
This is a Button
</button>
Put your button2 class in CSS file and add it in your HTML page.
Upvotes: 0
Reputation: 213
Hope this will help you
<!DOCTYPE html>
<html>
<head>
<style>
.button2 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
</head>
<body>
<button class="button2">
This is a Button
</button>
</body>
</html>
Upvotes: 0