PDA

View Full Version : Custom Buttons for your site.


Mike Lane
Mar-28-2006, 05:32 PM
So Andy asked here (http://www.dgrin.com/showthread.php?t=30813) if I could enlighten people on if and how you can create custom buttons. You can't.

Just kidding. Let's say you don't really care too much about creating images. You're just looking to get by with a nicer looking albeit not too fancy. The first thing you have to do is to target your buttons. Fortunately JT has made this easy by calling classing them either with buttons or smbuttons. Basically the difference is that the .buttons are ones that you'll see when you're logged in and they have a larger font and the .smbuttons are ones that will show up for various user interface items on your site - e.g. when you add a comment and you select add comment or cancel those are .smbuttons.

So to change them up a bit you can do what I've done on mikelane2.smugmug.com (http://mikelane2.smugmug.com) (as of today - this may change):

.buttons,
.smbuttons { /* select the normal state buttons */
background:#7d7d7d; /* set the background color */
color:#e7e6e6; /* set the text color */
border:3px outset #7d7d7d /* make it look slightly 3d using only CSS */
}

.buttons:hover,
.smbuttons:hover { /* select the hover state of the buttons */
background:#9e9d9d; /* make the background color a bit lighter */
color:#222; /* change the text to be a bit more readable on the lighter bg */
border-color:#ad9d9d; /* change the border color but not the border style */
}

.buttons:active,
.smbuttons:active { /* select the button state when the mouse is clicked */
background:#9e9d9d; /* set the background color */
color:#222; /* set the text color */
border:inset #ad9d9d; /* change the border to an inset border so it looks as if the button has been pressed */
}

You'll notice that I have chosen to make both sets of buttons look the same. You can do that too or you can make them look entirely different. With a little more specificity you can make them different on each different page of your site. But here, I made them all the same site-wide.

"Awesome! Uh, but wait it doesn't work in my browser. :dunno "

Well that's because you're using the world's worst browser, Microsoft IE6. MSIE doesn't recognize the :hover and :active states on anything but <a> elements. However, you'll notice that the buttons look just fine even though they don't change in IE. This is called degrading gracefully.

But let's say you want to do something like I've got on my site (http://photos.mikelanestudios.com/date/) - notice the "browse" button? :wink (IE isn't hacked as of yet so it'll look bad there, but that will change eventually...) The steps are eeerily similar to the ones above except you have to do a bit of work first. You need to create yourself a button. But you don't want it to be any ordinary button. No, no. You want it to be 2 buttons in one. Why? Well so you can do CSS sprites of course!

Now, I can't very well justify just giving away my buttons now can I? So what I did was to create you a set of your own. These are super easy even if you're a Photoshop clown. All you have to do is use the rounded rectangle tool and set a layer style and save it as a png. That's exactly what I did and it takes all of 2 minutes.

http://mikelane.smugmug.com/photos/61997394-O.png

See? 2 buttons in one. You could even do 3 if you're feeling feisty! We'll make it so only one of the colors will show at any given time by using the :hover and :active pseudo classes and a little background positioning. So let's assume again that you want all of your buttons to look the same. Once you get that image (or your own image) saved to your site (please don't steal my bandwidth!) simply copy the URL down and then use a code like this:

EDIT: You know what I love? IE. Love it. I should have realized that IE would try to squash the two pills above into one compact little area thus leaving Andy broken and sobbing. Well buck up Andrew! All we'll need is a quick fix. First thing you need to do is to create an entirely new button just for IE. This time with only one pill. If you're a photoshop jester like me you can simply go into the psd, copy one of the pill layers into a new document, crop, save and post like so:

http://mikelane.smugmug.com/photos/62023846-O.png

Now upload that button to your smugmug site, note the URL, and use it in the magenta code below. My God I hate IE.

EDIT 2: I still hate IE... The default value for the background property is transparent if you leave it out like I did. Guess who doesn't know that? The IE developers. Yay! So add the yellow now. I think I'm going to run out of colors soon at this rate.

EDIT 3: Well I'm a complete moron... Duh, if the background is defined with a png and not overridden in IE of course it's not going to be fixed. So ignore edit 2 and revel in the edit 3 sea green goodness.

.buttons,
.smbuttons { /* select all the normal state buttons */
background:url(/photos/XXXXXXXX-O.png) top no-repeat; /* set the background to your uploaded image file and make sure the top is at the top and it doesn't repeat; */
_background:transparent;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (enabled=true, sizingMethod=scale, src='/photos/YYYYYYYY-O.png'); /* make IE able to handle the png transparency */
border:0; /* we don't want a border for this example */
height:20px; /* Set the button height to be the same as the height of one of your buttons */
width:85px; /* Set the button width to be the same as the width of your buttons */
color:#000; /* set a text color that is readable on that button */
}

.buttons:hover,
.smbuttons:hover { /* select the hover state for the buttons */
background-position:bottom; /* Our hover state is on the bottom so make it so the bottom of the background image is at the bottom of the container */
border:0; /* still no border on the hover */
height:20px; /* make double sure the dimensions don't change */
width:85px;
color:#000; /* set a text color that is readable on that button */
}

.buttons:active,
.smbuttons:active { /* very optional */
position:relative; /* needed for the next set of rules */
top:1px; /* these 2 make the button move down and right one pixel as if it were being pushed downward */
left:1px;
}


The other thing you're going to have to do is to hack IE to make it so the buttons work. That is the code that I highlighted in purple above. Just slip the same number replacement for XXXXXXXX in there as you did for the background image url right above it.

And there you have it. Fancy pants buttons. Don't be afraid to stray away from the mac-ish conformity of the plasticy-glassy gell-like button either!

Andy
Mar-28-2006, 07:31 PM
http://williams.smugmug.com/photos/53333638-L.gif

There's an example in the bio box on my demo site:
http://andydemo.smugmug.com/

Very very nice, Mike :bow thank you for the tute. :clap

Mike Lane
Mar-28-2006, 07:32 PM
Hey, no problemo! Maybe I should do a photoshopping buttons tutorial too eh? :wink

That'll have to wait a bit.

peestandingup
Mar-28-2006, 08:43 PM
Maybe I should do a photoshopping buttons tutorial too eh? :wink For those who dont have photoshop. Try this! (http://www.buttongenerator.com/)

Mike Lane
Mar-28-2006, 09:07 PM
For those who dont have photoshop. Try this! (http://www.buttongenerator.com/)

Interesting. Just make sure not to add any text to your button.

dogwood
Mar-29-2006, 01:57 PM
[quote=Andy] http://williams.smugmug.com/photos/53333638-L.gif

There's an example in the bio box on my demo site:
http://andydemo.smugmug.com/

Andy:

FYI, when I click on your link, it says I need a password to continue.

Andy
Mar-29-2006, 02:07 PM
FYI, when I click on your link, it says I need a password to continue.

Sorry bout that :D I was testing something and forgot to turn that password off.

It's fixed now. :thumb

kkrasin
Oct-02-2007, 04:51 PM
I know this is an old thread, but...

I changed the buttons on my site & I love how it looks. But my "share photo" button didn't get changed! Is there anyway to do it without making a picture to put there?

Thanks!

Kendra Krasin
kkrasin.smugmug.com

Mike Lane
Oct-02-2007, 05:19 PM
I know this is an old thread, but...

I changed the buttons on my site & I love how it looks. But my "share photo" button didn't get changed! Is there anyway to do it without making a picture to put there?

Thanks!

Kendra Krasin
kkrasin.smugmug.comYour share photo button is an image that is classed with share_button so it won't change if you use the .smbutton or .button class. And, no, there isn't any way to change it without using an image.

Once you get an image, just use something like this:


img.share_button {
width:59px;
height:21px;
background:url(/photos/151583757-O.gif);
_filter:none;
}

That's straight from another site I did. You'll need to change the stuff in red.

Errr, you may need the IE fix in blue – er, blue is too hard to read, so the stuff in lime – , but you may not. It's been too long heh :D

poleinajeep
May-07-2008, 09:28 PM
i really like the buttons in the smugmug gradient theme.

is there an easy way to bulk enable those buttons in my current theme?

beachglassphotography.com (http://beachglassphotography.com)

BOM
May-26-2008, 09:57 AM
I am looking to use the Gradient Grey buttons as well. If you know the path, I believe it can be done. I have seen the following example and it works.

.play_slideshow {
.
.
background: url(/img/themes/BlackArts/playSlideshow.gif) no-repeat;
.
.
}

BOM
May-26-2008, 11:00 AM
OK. I figured it out. Here's what I did.

1) Changed to the theme with the buttons I wanted.
2) Using the wonderful Firefox developer plugin (http://chrispederick.com/work/web-developer/) I viewed the 'theme' CSS sheet added by selecting CSS -> Edit CSS.
3) Looked at the CSS button code and used pieces of the code in my own CSS.

Worked great!

Oakley
May-31-2008, 08:25 PM
OK. I figured it out. Here's what I did.

1) Changed to the theme with the buttons I wanted.
2) Using the wonderful Firefox developer plugin (http://chrispederick.com/work/web-developer/) I viewed the 'theme' CSS sheet added by selecting CSS -> Edit CSS.
3) Looked at the CSS button code and used pieces of the code in my own CSS.

Worked great!


That works as long as there isn't a button that links in to a url image - like slideshow or mapthis. Those are the ones I'm having problems with. I wish smugmug would just post those images that they are using on their gradient theme. I've asked a couple of times now in different places and haven't had a response on that one....not sure why.

Andy - if you see this one, could you let us know your thoughts?

Thanks

Ryan

EDIT: Nevermind --- Here's what I did - similar to someone else's steps above.

1. Open up one of my galleries.
2. Log in
3. Choose different themes until you find the buttons you like.
4. Use Firefox web developer tool to find the theme css.
5. Search for "buttons" and/or "slideshow".
6. Find the url to the buttons and copy/paste it in a new tab
7. Right click - File Save As
8. Photoshop it, save it, load it as your own.

Hope that is clear...

Andy
May-31-2008, 08:42 PM
Andy - if you see this one, could you let us know your thoughts?

Thanks

Ryan
Have you viewed source? We don't hide them :D


http://cdn.smugmug.com/img/sm_buttons/play_slideshow_black.png

http://cdn.smugmug.com/img/sm_buttons/map_this_black.png

http://img.skitch.com/20080601-m476e3wjk1e7uhx8a4ijb7hwxi.jpg

johnnabrynn
Jun-10-2008, 06:05 PM
Have you viewed source? We don't hide them :D


http://cdn.smugmug.com/img/sm_buttons/play_slideshow_black.png

http://cdn.smugmug.com/img/sm_buttons/map_this_black.png

http://img.skitch.com/20080601-m476e3wjk1e7uhx8a4ijb7hwxi.jpg

hi andy. i'd like something similar to sm's little black buttons -when i hover. i just want simple. i want white lettering floating (black button, but with my black bkground of homepage, u cant see it), and then when it hovers, i'd like a black glossy (or dark gray if u cant see it well enough) button. also, i'd like my font style to look like it has more resolution! i've searched high and low and cant get exactly what i need. hope u can help me. thanks!
johnnabrynn.smug

Oakley
Jun-10-2008, 10:13 PM
Have you viewed source? We don't hide them :D


http://cdn.smugmug.com/img/sm_buttons/play_slideshow_black.png

http://cdn.smugmug.com/img/sm_buttons/map_this_black.png

http://img.skitch.com/20080601-m476e3wjk1e7uhx8a4ijb7hwxi.jpg

Andy, I just went into my site to work on the buttons and found that the images now point to a location on my www.thepup.smugmug site! So I don't have to find the locations via the source code for the theme, copy them on my computer, upload them to my smugmug site and then link to them in my CSS. Great!

One questions - I'm not getting my "add comment" button to change like the rest of them?

Can anyone help me troubleshoot that? It's an smbutton, but I can't see how I'm messing things up with my CSS.

Cheers,

Ryan

richW
Jun-10-2008, 11:02 PM
Andy, I just went into my site to work on the buttons and found that the images now point to a location on my www.thepup.smugmug (http://www.thepup.smugmug) site! So I don't have to find the locations via the source code for the theme, copy them on my computer, upload them to my smugmug site and then link to them in my CSS. Great!

One questions - I'm not getting my "add comment" button to change like the rest of them?

Can anyone help me troubleshoot that? It's an smbutton, but I can't see how I'm messing things up with my CSS.

Cheers,

RyanThis one Ryan?


.add_comment {
width: 110px;
height: 0px;
border: none !important;
padding-top: 18px;
overflow: hidden;
color: transparent;
font-size: 0px;
background: transparent url(http://www.thepupil.ca/img/sm_buttons/add_comment_black.png) no-repeat;}

atom k
Jun-19-2008, 04:31 PM
Right now, I have a dropdown button created with CSS code. Here's (http://adamkobrin.smugmug.com/On%20the%20Road) one example.

now I've created a much cooler button in Photoshop. My question is, where do I put the code to access the new button? The code I have now is from the Dgrin page for the Easy Navbar (http://www.dgrin.com/showthread.php?t=42747&highlight=slideshow+padding) . I assume I need to plug it in somewhere in this code, plus I want to keep the second level dropdown the way it is in the original code.

Thanks.