Hover in CSS
-
Dear Ben,
I hope this finds you well!
I am finally getting a better idea of how to do small things in CSS.
I am trying to create a CSS code for some of my links with hover, for which I was using image blocks and a plugin so far.
See the following page:
https://www.samvriti.com/tests-hover-css/
First half: images + plugin. Second half: CSS.
The CSS have I used:
.background-switch { text-align: center; max-width: 300px; margin-left: auto ; margin-right: auto ; padding: 1em; border-radius: 30px; border: 1px solid #f4f4f4; background-color: white; } .background-switch:hover { color: #7B7B7B; background-color: #141414; transition: width 2s; transition-timing-function: linear; }
A few things I am not yet able to figure out:
– Which exact tag am I to add to make the whole block as link (and then possibly adding further css functions for link, visited, over, active), instead of the text within? And/or, to cancel the hover style for text, if this text is placed in this background hover change?
– How to apply at once a flexible width, which would define itself according to the length of the text each time, but also so that the whole background remains centered in the page? It seems it is either/or with the present code ( margin-left: auto ; and margin-right: auto ; seem to require a fixed max-width).
Thanks Ben !
Samuel
- The topic ‘Hover in CSS’ is closed to new replies.