Display a Custom CSS Button on Page?
-
I am trying to create a CSS button with some pseudo elements that I found here: https://tympanus.net/codrops/2012/01/11/css-buttons-with-pseudo-elements/
I have the following code in my Child Themes style.css:
.a_mybutton { background-color:#3bb3e0; font-family: 'Open Sans', sans-serif; font-size:12px; text-decoration:none; color:#fff; position:relative; padding:10px 20px; border-left:solid 1px #2ab7ec; margin-left:35px; background-image: linear-gradient(bottom, rgb(44,160,202) 0%, rgb(62,184,229) 100%); border-top-right-radius: 5px; border-bottom-right-radius: 5px; box-shadow: inset 0px 1px 0px #2ab7ec, 0px 5px 0px 0px #156785, 0px 10px 5px #999; } .a_mybutton:active { top:3px; background-image: linear-gradient(bottom, rgb(62,184,229) 0%, rgb(44,160,202) 100%); box-shadow: inset 0px 1px 0px #2ab7ec, 0px 2px 0px 0px #156785, 0px 5px 3px #999; } .a_mybutton::before { content:"·"; width:35px; max-height:29px; height:100%; position:absolute; display:block; padding-top:8px; top:0px; left:-36px; font-size:16px; font-weight:bold; color:#8fd1ea; text-shadow:1px 1px 0px #07526e; border-right:solid 1px #07526e; background-image: linear-gradient(bottom, rgb(10,94,125) 0%, rgb(14,139,184) 100%); border-top-left-radius: 5px; border-bottom-left-radius: 5px; box-shadow:inset 0px 1px 0px #2ab7ec, 0px 5px 0px 0px #032b3a, 0px 10px 5px #999 ; } .a_mybutton:active::before { top:-3px; box-shadow:inset 0px 1px 0px #2ab7ec, 0px 5px 0px 0px #032b3a, 1px 1px 0px 0px #044a64, 2px 2px 0px 0px #044a64, 2px 5px 0px 0px #044a64, 6px 4px 2px #0b698b, 0px 10px 5px #999 ; }
But how do I call this custom button to display in either my post content or sidebar? I have tried making a shortcode of this button by writing the following into my functions.php:
function mybutton($atts, $text = ''){ extract(shortcode_atts(array( 'text' => '', 'link' => '' ), $atts)); $html = '<a href="' . $link . '"><div class="myButton">' . $text . '</div></a>'; return $html; } add_shortcode('mybutton', 'myButton');
But this just adds a unstyled link of the text I enter, it doesn’t use the custom CSS styling.
Am I just missing something while trying to create a shortcode? Or do I need to call the CSS button using a different method?
Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display a Custom CSS Button on Page?’ is closed to new replies.