is there a way in CSS to get the initial parameter of something, without using javascript, for example:
width: calc(initial-20px);
if so, ho can i retrieve the value of specific parameters, like width.initial?
SCENARIO
It's a visual studio web browser, (it doesn't support css3 by default), i whant an element to look like highlited, but i can only do it through html attributes(i wanna go the easy way). So i could just style="background-color: yellow !important;"
, but what if background is already yellow? So i decided that calculating the highlight color would fix be awesome ( as i know now it is impossible through css ) background-color: rgb(initial,calc(initial-50),initial) !important;
something like that. So this is a scenario. Suggestions are apreciated.
calc() The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a <length> , <frequency> , <angle> , <time> , <percentage> , <number> , or <integer> is allowed.
The initial value of a CSS property is its default value, as listed in its definition table in the specification. The usage of the initial value depends on whether a property is inherited or not: For inherited properties, the initial value is used on the root element only, as long as no specified value is supplied.
The initial CSS keyword applies the initial (or default) value of a property to an element. It can be applied to any CSS property, including the CSS shorthand property all .
Example of using the calc() function with CSS variablesUsing calc() with CSS variables, we can define a value once and modify it using math in order to get a new value which will be useful for us.
Simply put, no it is not possible to do this with css. You also can't perform calculations like that. You can only do calculations for percentages, like Mooseman said (edit: Mooseman deleted his answer. It mentioned that you can use width: calc(100% - 40px);
for example, but you can't use initial
like that). for either of those things you would need to use JavaScript.
Edit: Another option for modifying width could be a margin
, although that doesn't necessarily do exactly what you want. For highlighting, you could use something like this:
p {
background-color: #FFFF00;
}
p:hover {
background-image: linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.4));
}
<p>Example paragraph with background</p>
This way you overlay a translucent white layer on top of your background-color
, making it a bit lighter. That way you can change the background colour without having to know what the original background was.
i think you can Use LESS.
You Can See Here: http://www.ibm.com/developerworks/opensource/library/wa-less/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With