I did say earlier that I do not want anything gaudy. However, for sighted users, I think it i snice to have visual clues when it comes to buttons, like mimicking that the button is being clicked.
Have been looking around at images of buttons, and I think I am recalling what I saw and liked in the past.
I think the button used a gradient, and when you hovered over it/clicked on it, the gradient flipped vertically. And in doing so, it gave you the perception that your click was depressing the button like in real life. (I think in the past you did that with a gradient image slice, and maybe adjusted the position of the image so you got that shifting effect.)
But maybe there is a way to do that now just using CSS?
Try the good old fashioned method of setting the border to outset and inset when clicked. I prefer to set the outset colour to transparent and display a different colour for the border when selected.
Changing the selected border width appears to make the button sightly move.
Give it a whirl or do you only want to cut & paste a solution?
No, I am unsure if there is a way to make gradient background shading inside the button using CSS. And also if there is a way to flip that.
Like having the background shading be darker at the top of the button and slowly fade to a lighter shade. And then when you hover, that paradigm flips.
Sorry, all I know is old-school CSS2, so I’m not sure what all is available these days - for instance, I would have never guessed in a million years you could do what you did with your “silly” button!
It looks pretty close to what I want, but I could use help with the following…
1.) I don’t understand how to make :active work
2.) I read up on MDN about background: linear-gradient, but didn’t really understand it. I want the shading to start off with Gold but then transition to the Darker Orange later on. It seems like the Darker orange happens too soon.
3.) How do you make the gradient line vertical?
4.) How do I center my button vertically and horizontally in the surrounding back?
5.) Anything else I could do to make my button look better?
Not sure what you were trying to do with the button?!
I was reading an article that said you should style buttons when they are depressed/clicked (i.e. “active”) to give the user feedback.
I was thinking it might look good to make the button an even darker orange when it is clicked. But in the code I posted above, it seems that my pseudo-class (?) isn’t working.
I guess I’m not understanding what :active and :focus do. Based on the article I was looking at earlier, I was expecting :active to apply a style as I was clicking on the button, but once I released, then it would go back to the regular style.
When I add your code, when I hover over the button, its look changes. But then clicking on the button does nothing new. And after clicking on it, it does look different, though.
I thought the author was suggesting - which would make sense to me - that you want to apply a style (typically a darker button) as the user clicks on it to make it look like it is being depressed I suppose.
Am trying to play around with things, but my original code wasn’t working…
The code that I gave you in post #34 started with
a “golden gradient background”, turned “red” on
hover and “black” on active ( mousedown ). If you
require “black” when clicked then you would need
…so that myButton:hover would function
correctly.
It did not need to be added to myButton:active
because the “hover” state remains.
You will notice, though, that I have included it for "focus".
The backgroundshorthandCSS property sets all
background style properties at once, such as color,
image, origin and size, or repeat method.
The background-imageCSS property sets one or
more background images on an element.
background-image overrides background-color,
so background-image: none; needs to be applied
for the hover, active or focus to work.