+ 9

just by using css and html is it possible to write a code that when we click an element its class changes to our wished class?

i mean change in attribute values just by using css

26th Jul 2018, 10:11 PM
SIMA
SIMA - avatar
5 ответов
+ 8
Using CSS target selector, it's possible to add any class to the clicked element. Set the element with and href attribute to an id that points to itself. eg. <a href="#self" id="self">Click here to change border and background color</a> Set your wish class as: .wish, :target { /* wish class */ border: 1px solid steelblue; background-color: beige; } Check out the sample here https://code.sololearn.com/Wa5ScJFX1IEE/?ref=app
27th Jul 2018, 12:55 AM
Calviղ
Calviղ - avatar
+ 3
When it comes to values, it depends on the specific situation. The value itself wouldn't change, but it may be possible to trigger the use of a different set of values when the user clicks. On-the-fly class changing requires JavaScript.
26th Jul 2018, 10:20 PM
Janning⭐
Janning⭐ - avatar
+ 1
No CSS is used for styling the document and for basic logic (e.g. :hover). You would have to use JS to achive such effect.
26th Jul 2018, 10:20 PM
TurtleShell
TurtleShell - avatar
- 5
3
27th Jul 2018, 12:58 AM
lol
- 6
3
27th Jul 2018, 12:58 AM
lol