This question already has an answer here:
Can Sass evaluate strings that contain mathematical expressions?
(1 answer)
Closed 7 years ago.
In Sass I have a string, for example 1px + 1px.
Can I evaluate this string, using Sass, to get 2px result?
You have an actual string?
as in $foo: "1px + 1px";
because no, in Sass you can't do anything like that, but you can just add numbers together so 10px + 100px will equal 110px
See this pen: http://codepen.io/anon/pen/MwEgrX
Related
This question already has an answer here:
Sass extend and parent selector
(1 answer)
Closed 1 year ago.
I'd like to generate the content of a %-class within a pseudo selector. #extend works rather unexpected here. Can someone tell me how I would get the expected CSS?
My SASS
%ext
&:aaa
color: red
button
&:bbb
#extend %ext // expected: .button:bbb:aaa
Actual Generated CSS
button:aaa:bbb {
color: red;
}
Expected CSS
button:bbb:aaa {
color: red;
}
The answer is: The order doesn't matter for the resulting CSS.
Therefore: Don't mind.
This question already has answers here:
how to center an inline div using css?
(5 answers)
Closed 7 years ago.
Hi i am currently working with rails 4.2 and using sass , and haml . I am trying to center align the h5 that i have but it seems that it doesnt want to cooperate with me and i already tried with the search with google but still a fail
this is my code
the static page is this
.row#mod
.container#space
.row
.col-md-2
.thumbnail
.caption
=image_tag "a.png", tag: "",class: "img-thumbnail"
%h5
%b#tag Lead
%br
The sass is this
#tag
text-align: center
but the center alignment of the h5 is still to no avail can anybody help me and thanks
The id tag is on the inline element <b>, so text-align: center won't center it within the block h5 element. You can either make #tag display: block, or you should move text-align: center to the h5.
Example 1:
#tag
display: block
text-align: center
Example 2:
.caption h5
text-align: center
This question already has answers here:
Sass calculate percent minus px
(6 answers)
Closed 7 years ago.
I have a margin that's defined in em.
I want to do
width: 100% + 3em;
but the units won't play nice.
In my local development environment, I got it to work with interpolation like so
width: #{100%} + #{$code-padding-h};
But when I try to precompile, the precompiling fails with this error
Sass::UnitConversionError: Incompatible units: 'em' and '%'
You can do this trick with the calc method in your css:
width: calc(100% + 3em);
This question already has an answer here:
Append the parent selector to the end with Sass
(1 answer)
Closed 7 years ago.
you surely know reverse nesting in sass. So i got an advanced question for you.
.profile{
.avatar{
color: blue;
.friends &{
color: grey;
}
}
}
Compiles to:
.friends .profile .avatar {
How to get a result like:
.profile.friends .avatar {
Is there a solution with out changing the structure of the sass.
No, you must change the structure of the Sass. The upcoming #at-root feature can partially unwind selectors, but it will not work in this instance.
This question already has answers here:
Sass negative variable value?
(6 answers)
Closed 7 years ago.
I can't use shorthand when I need to use variable arithmetic in SASS,
This is expected result:
text-shadow: 0 -2px white;
But when I code this:
$shadow: 2px;
text-shadow: 0 -$shadow white;
But I get this:
text-shadow: -2px white;
How to fix that?
Found a solution:
text-shadow: 0 #{-$shadow} white;