This question already has answers here:
Sass Variable in CSS calc() function
(6 answers)
Closed 8 years ago.
Is there anyway to force emCalc to run in Foundation. For example I have this code.
.rule {
height: calc(100% - emCalc(10px));
}
The sass simple produces exactly that, without running the emCalc function. Is there anyway to force the sass processor to run the emCalc function first?
You can do it like this:
.rule {
height: calc(100% - #{emCalc(10px)});
}
Related
This question already has answers here:
Using regular expression in css?
(6 answers)
Closed 2 years ago.
A JS library I am using is creating a new class every time I switch the page.
Something like:
.marquee0
.marquee1
.marquee2
.marquee3
.marquee4
.marquee5
.marquee6
...
Is there a way I can minify this in my css for an infinite amount of numbers?
At the moment I use this:
.marquee0, .marquee1, .marquee2, .marquee3, .marquee4, .marquee5, .marquee6 {
}
Thank you in advance!!
Yes there is a way! The CSS contains selector
div[class*="marquee"] {
background: #ffff00;
}
will give all those a background color.
This question already has answers here:
Sass Variable in CSS calc() function
(6 answers)
Closed 4 years ago.
Problem :
Correct use of calc function with sass file.
Case :
.class1 {
max-width: calc(100% - #{$endWidth});
min-width: $startWidth;
text-overflow: ellipsis;
}
.class2 {
max-width: calc(100% - #{$startWidth});
direction: rtl;
}
Tried Case :
I have verified few answers in stack overflow, and from one of the question answers inspired my question - Stack Overflow Reference. The solutions aren't working for my scenario,
Should I use mixin in sass to get it to work ?
While calc() will indeed cause issues with SASS files by default, this can be avoided by using interpolation (which you are using correctly).
The only possible explanation(s) for your issue are:
You do not have (or have it incorrectly defined) SASS variables:$startWidth and $endWidth
Rules with higher specificity are overriding your selectors
You have cached old styles, hence clear your cache with CTRL + SHIFT + R
Here's an example JSFiddle showcasing your above code working.
This question already has answers here:
How to prevent Less from trying to compile CSS calc() properties?
(4 answers)
Closed 7 years ago.
This is a question that has been asked several times before, but none of the answers I have found seem to work in my case. I have 3 buttons and I am trying to evaluate their width as follows:
.num-buttons-3 {
width: calc((100% - 40px)/3);
}
This always evaluates in my browser (Chrome) as 20%, which is (100% - 40%)/3.
I have tried numerous suggested alternatives to get this to evaluate correctly, such as:
.num-buttons-3 {
width: calc((~'100% - 40px')/3);
}
.num-buttons-3 {
#marg: 40px;
width: calc((~'100% - #{marg}')/3);
}
Is therer another CSS or LESS solution I can try?
Found an answer on this. Escaping the entire calc function is an option that seems to work:
width: ~"calc(((100% - 40px)/3))";
This question already has answers here:
Can I programmatically determine a property value for a series of CSS classes?
(2 answers)
Closed 7 years ago.
I have many lines of CSS that essentially do the same thing over and over based on the class name:
.m45 {
height: 90px;
}
.m50 {
height: 100px;
}
.m55 {
height: 110px;
}
.m60 {
...
Is there any way to automate this so that a class that matches m followed by any number n gets the style height: calc(2px * n)?
No, CSS can't automate increases like this; it doesn't have support for functions like that. You can, however, use a CSS pre-processor like Sass to write shorter code that can handle things like a #for loop. Sass compiles into longer, normal CSS.
This question already has answers here:
Is it possible to make a div 50px less than 100% in CSS3? [duplicate]
(6 answers)
Closed 10 years ago.
Is it possible somehow to calculate size of an element as a basic mathematical expression?
e.g.:
.wideColumn{max-width:100%-20em;} /*not working*/
This can be accomplished using LESS or jQuery. But unfortunately it cannot be done with pure CSS.
There are, however, workarounds to this issue using pure CSS. For example:
.wideColumn {
max-width: 100%;
margin-right: 10em;
margin-left: 10em;
}
Of course, this example may not work with your code. But there are numerous other workarounds.
Short answer is NO you cannot, not atleast in CSS 2, 2.1 spec, then too if you are interested you could take a look at Dynamic stylesheets with LESS
Or as Sandeep told, you can use calc() which is introduced in CSS3 spec
Reference
You cannot do this in CSS directly, but try something like LESS - http://lesscss.org/
it might be available one day, but not now - read more here http://www.w3.org/Style/CSS/specs#math