HTML/CSS - Adding An Icon To A Button
I making some css buttons and I want to add an icon before the text, 'Button Text'. But I dont know how I should do this... HTML
Solution 1:
You could add a span before the link with a specific class like so:
<div class="btn btn_red"><span class="icon"></span><a href="#">Crimson</a><span></span></div>
And then give that a specific width and a background image just like you are doing with the button itself.
.btn span.icon {
background: url(imgs/icon.png) no-repeat;
float: left;
width: 10px;
height: 40px;
}
I am no CSS guru but off the top of my head I think that should work.
Solution 2:
Solution 3:
<a href="#" class="btnTest">Test</a>
.btnTest{
background:url('images/icon.png') no-repeat left center;
padding-left:20px;
}
Solution 4:
Simplest button with emoji icon
button {
line-height: 25px;
}
button::before {
content: "🔎 ";
}
<button>Search</button>
Post a Comment for "HTML/CSS - Adding An Icon To A Button"