-1

Usually I set the hover style of a link by the pseudo-class as shown at e.g. W3Schools.

a:hover { border: solid; }

However, on the current project, I'm only able to control the styles being assigned, not the classes. So, I'm only allowed to provide a statement as follows:

formats.Add("border", "solid");

if I want to affect the looks of the product. Is there a CSS version of style that makes the link look one way or the other? In this particular case, all the effects (hover, active etc.) are supposed to look the same, if it makes it any easier.

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • Try `formats.Add("border", "2px solid green");` – Pugazh May 23 '16 at 11:25
  • 1
    Can you give more explainations about the technology you user to control styles, as showed in your formats.Add() example? – gbalduzzi May 23 '16 at 11:26
  • I think, this will help you [http://stackoverflow.com/questions/1033156/how-to-write-ahover-in-inline-css](http://stackoverflow.com/questions/1033156/how-to-write-ahover-in-inline-css) – g4GG May 23 '16 at 11:28
  • here is your answer [How to add style from code behind?](http://stackoverflow.com/questions/2004720/how-to-add-style-from-code-behind) – dippas May 23 '16 at 11:34
  • @Pugazh Not sure I follow. It's not equivalent to the style in my example **and more importantly** it doesn't address the hovering state. Or am I misreading it? – Konrad Viltersten May 23 '16 at 12:27
  • @gbalduzzi The technology is CSS styling HTML. The problem is that **I can't** affect all the parts of the code. I'm only allowed to provided a list of style-value-pairs. – Konrad Viltersten May 23 '16 at 12:29
  • You can add styles to a tag with some class? e.g. `a.hovered`? – Mohit Bhardwaj May 23 '16 at 12:59
  • @Mike I can't do that, sadly. Please see the second paragraph (between the code samples). :) – Konrad Viltersten May 23 '16 at 13:02
  • You need to edit your question to make it a lot clearer what you are asking. The first line of code you provided (`a:hover{...}`) will do *exactly* what you want to achieve. The `formats.Add()` code is provided completely without context so there's no way we can address that. What do you mean by "CSS version of style"? – Shaggy May 23 '16 at 15:50
  • @Shaggy I'd gladly improve the question to be more clear. However, I'll need some help with that. You seem disregard the main circumstance, as if it was something optional. The situation is **precisely** as I describe, i.e. I'm not in a position of using a class *:hover* because **in this project** that **my** question treats, I'm only allowed to provide the pairs of style and value. If I was in another project with more control over the code, I wouldn't have to ask (as I show in the first example). Please take a peek at the second paragraph (between the lines of code). Hope this clears it up. – Konrad Viltersten May 24 '16 at 18:48
  • OK, so, if I'm reading everything correctly here, you have absolutely no direct access to the CSS; you can only modify it via some form of scripting, as illustrated in your 2nd code snippet. You're still going to have to expand on that to provide us with more information about what it is and how it works as, out of context like that, it tells us absolutely nothing. If you have access to the JS, as it appears you do, you could easily replicate the `:hover` effect by using the `mouseover` & `mouseout` events. – Shaggy May 24 '16 at 18:59
  • @Shaggy That's correctly understood - I have no access to the CSS. And take a wild guess if I can manipulate the JS, hehe. In this particular case, I'm only allowed to check something like this: *[{'s':'border','v':'solid'},{'s':'color','v':'green'}]*. Yes, I can imagine your eyebrows hitting the roof. And yes, I am serious. That's what the customer demands. – Konrad Viltersten May 24 '16 at 19:30

1 Answers1

0

You can't do that this way. In practice, there are only tow options.

  1. User class and affect the elements the right way.
  2. Forget about it and try to work another angle.