Buy me a coffee

How to attach a logo to a button

Suppose you need to attach a logo to a specific button block. You can follow these.

#1. Find Logo URL
#2. Find Button Block ID.
In my example, we will have: #block-yui_3_17_2_1_1723015693923_4061

4cb509ea1ab1bcefe5a0 Min

#3. Use this code to Custom CSS box

#block-yui_3_17_2_1_1723015693923_4061 a:after {
    content: "";
    background-image: url(https://cdn.pixabay.com/photo/2024/08/30/10/15/woman-9009013_1280.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    display: inline-block;
    width: 100px;
    height: 50px;
}

772e4800515bf705ae4a Min

#4. Result

27fad272ca296c773538 Min

#5. If you want to move logo before text, just change
:after
in the code to
:before

405edc9bc0c0669e3fd1 Min

#6. If you want to make logo above button text, add this extra CSS

#block-yui_3_17_2_1_1723015693923_4061 a {
    flex-direction: column;
}

B549399639cd9f93c6dc Min

Result

Bdae76cd7696d0c88987 Min

#7. If you want to add this to Header button, use this new CSS code

a.btn:after {
    content: "";
    background-image: url(https://cdn.pixabay.com/photo/2024/08/30/10/15/woman-9009013_1280.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    display: inline-block;
    width: 100px;
    height: 50px;
}
a.btn {
  display: flex !important;
  align-items: center;
}

9330199d1dc6bb98e2d7 Min

Result

09cbd2d9d68270dc2993 Min