0

I have a css conflict between share point 2013 core css and my css. So I want to put all my class under div #s4-workspace But I search about a way to grouping all classes under this div like in media query in css

=> for example

 #s4-workspace {

   input, button{css style}
   a,a:hover{css style}
   table{css style}
  .div1{css style}
  .div2{css style}
  .div3{css style}

}

is it possible in css3.

Thanks in Advance

1

1 Answer 1

0

Do you want to avoid repeating the id like:

#s4-workspace   input,
#s4-workspace   button,
#s4-workspace   a,
#s4-workspace   a:hover,
#s4-workspace   table,
#s4-workspace  .div1,
#s4-workspace  .div2,
#s4-workspace  .div3 {
  /* */
}

This is called nesting and no it isn't possible in CSS Level 3.

Any preprocessor has this feature like LESS and Sass, though.

EDIT: it appears you want the resulting CSS:

#s4-workspace   input,
#s4-workspace   button {
  /* CSS styles 1 */
}
#s4-workspace   a,
#s4-workspace   a:hover {
  /* CSS styles 2 */
}
#s4-workspace   table {
  /* CSS styles 3 */
}
#s4-workspace  .div1 {
  /* CSS styles 4 */
}
#s4-workspace  .div2 {
  /* CSS styles 5 */
}
#s4-workspace  .div3 {
  /* CSS styles 6 */
}

Same answer: not possible in CSS Level 3 though it can be compiled from a .less or .scss file (which would be very similar to your example of code). Those 2 preprocessors allow nesting as one of their basic features.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks, I know this way to apply one style for all tags. But what I need to add more tags and style for each one under one dive as a parent. like media query => @media {...classes here...} check it again : #s4-workspace { a {color:#000} button {border:1px} inbut {background: #fff} }
Oh I did 2 things in my example: adding id at the beginning of each selector and merging styles that I thought were commons. I'll edit my answer
Thanks again for your effort, Now I'm sure it is not possible in CSS3 and I must use .less or .scss. - Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.