I am trying to create me a PX/REM converter in LESS CSS but I am facing a problem.
The following lines do not want to compile, the problem comes from #{propertyValue}:.
.rem(#propertyValue; #sizeValue) {
#remValue: #sizeValue / unit(#base-font-size);
#{propertyValue}: ~"#{remValue}rem";
}
But yet I think the syntax is good... at last I thought! Can you help me?
Thank you!
Are you using at least LESS 1.6? Variables as property names were added in 1.6. Prior to 1.6 there are some solutions but none are pretty.
Your snippet works in this LESS previewer which is running 1.6.0: less2css
I have 3 CSS classes defined:
table-header-shading
table-content-shading
table-lines
Normally I would use them like so:
<table class="table-header-shading table-content-shading table-lines">
However is it possible to defined a composite Class like "ReportTable" which is comprised of these 3 classes such that I can write the following:
<table class="ReportTable">
I suspect this is a basic CSS questions, but alluding me at present.
Many thanks in advance.
EDIT
Felix suggested something along the lines of
.ReportTable table-header-shading {}
.ReportTable table-content-shading {}
.ReportTable table-lines {}
To call
<table class="ReportTable">
However I am unsure whether my understanding is correct ??
EDIT2
I am sorted on this now. Thanks to all
It is not possible with "clean" CSS. If you will use LESS, you can do:
.ReportTable {
.table-header-shading;
.table-content-shading;
.table-lines;
}
I am trying to write a nested selector that selects a certain tag that has a certain attribute, for example
<li foo="bar">
To select this, li[foo="bar"] would work, but I want to nest it under [foo="bar"] using the scss & notation because I have other things with the [foo="bar"] attribute (e.g., <div foo="bar" class="baz">), and I want to group them together. When I try:
[foo = "bar"]{
&li{
...
}
&.baz{
...
}
}
It returns an error that says li may only be used at the beginning of a compound selector, and if I try:
[foo = "bar"]{
li&{
...
}
&.baz{
...
}
}
then it says & may only be used at the beginning of a compound selector. How can I do this correctly?
The right syntax nowadays would be li#{&}.
Last I heard, this is actually an upcoming feature in SASS 3.3 or 3.4.
See this thread for a question similar to yours and this thread for the proposed solution to be included (which, at the time of writing, seems to be &__element).
The issue here isn't the use of [] and & together - it's the use of a plain element in the selector. Your example with .baz should work as expected.
Like this
#ShuttleGrey: #606369;
I need same output color value from more variables [I am looking for a single line solution]
#themeOne:, #themeTwo:, #themeThree: #ShuttleGrey;
I know my code is an error , Does anyone know to fix this situation ?
Thanks
Assuming that you want the same properties to apply in many places you can do something like this
.aProperty{
color:#606369
}
Then you can do something like this to add the same properties to other elements
.anotherProperty{
background:#000; //just like that
.aProperty;
}
This way .anotherProperty will inherit the properties of aProperty.
This way you can even add other properties and use them at many places.
.aProperty{
color:#606369
}
Then you can do something like this to add the same properties to other elements
.anotherProperty{
background:#000; //just like that
.aProperty;
}
Since no answer is accepted I am trying my luck:)
This question already has answers here:
Multiline Comment Workarounds?
(11 answers)
Closed 9 years ago.
I found this old thread (from over a year ago), which explains how come R doesn't support a multi-line comments (like /* comment */ of PHP, for example).
I am wondering if this has been resolved in the past year, or if there are other alternatives? (For example, in notepad++ with npptor, you can mark a bunch of lines and press ctrl+q to mark them all as comments, are there similar solutions for other IDE's ?)
R Studio (and Eclipse + StatET): Highlight the text and use CTRL+SHIFT+C to comment multiple lines in Windows.
For macOS, use command+SHIFT+C.
You can, if you want, use standalone strings for multi-line comments — I've always thought that prettier than if (FALSE) { } blocks. The string will get evaluated and then discarded, so as long as it's not the last line in a function nothing will happen.
"This function takes a value x, and does things and returns things that
take several lines to explain"
doEverythingOften <- function(x) {
# Non! Comment it out! We'll just do it once for now.
"if (x %in% 1:9) {
doTenEverythings()
}"
doEverythingOnce()
...
return(list(
everythingDone = TRUE,
howOftenDone = 1
))
}
The main limitation is that when you're commenting stuff out, you've got to watch your quotation marks: if you've got one kind inside, you'll have to use the other kind for the comment; and if you've got something like "strings with 'postrophes" inside that block, then there's no way this method is a good idea. But then there's still the if (FALSE) block.
The other limitation, one that both methods have, is that you can only use such blocks in places where an expression would be syntactically valid - no commenting out parts of lists, say.
Regarding what do in which IDE: I'm a Vim user, and I find
NERD Commenter an utterly excellent tool for quickly commenting or uncommenting multiple lines. Very user-friendly, very well-documented.
Lastly, at the R prompt (at least under Linux), there's the lovely Alt-Shift-# to comment the current line. Very nice to put a line 'on hold', if you're working on a one-liner and then realise you need a prep step first.
CTRL+SHIFT+C in Eclipse + StatET and Rstudio.
if(FALSE) {
...
}
precludes multiple lines from being executed. However, these lines still have to be syntactically correct, i.e., can't be comments in the proper sense. Still helpful for some cases though.
No multi-line comments in R as of version 2.12 and unlikely to change. In most environments, you can comment blocks by highlighting and toggle-comment. In emacs, this is 'M-x ;'.
Put the following into your ~/.Rprofile file:
exclude <- function(blah) {
"excluded block"
}
Now, you can exclude blocks like follows:
stuffiwant
exclude({
stuffidontwant
morestuffidontwant
})
Unfortunately, there is still no multi-line commenting in R.
If your text editor supports column-mode, then use it to add a bunch of #s at once. If you use UltraEdit, Alt+c will put you in column mode.