Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point one style class to another?

Tags:

css

I have a css class like:

.foo {   background-color: red; } 

then I have a class specified for a list:

.list1 li {   background-color: tan; } 

is it possible to set one style class to just point to another? Something like:

.list1 li {   .foo; } 

not sure how to articulate that - I just want the .list li style to be whatever I define for the .foo class.

like image 230
user246114 Avatar asked Jun 14 '10 12:06

user246114


People also ask

How do I call one CSS class to another?

How do you call @extend? Instead of calling those classes in the html, we will tell the class to inherit the rules into its styling. In order to @extend the styling rules of a css class into another, you use the syntax @extend . classname; .

How do I select a class inside another class CSS?

Nested rules are defined as a set of CSS properties that allow the properties of one class to be used for another class and contain the class name as its property. In LESS, you can use class or ID selectors to declare mixin in the same way as CSS styles.

How do I inherit one CSS style from another?

The inherit CSS keyword causes the element to take the computed value of the property from its parent element. It can be applied to any CSS property, including the CSS shorthand property all . For inherited properties, this reinforces the default behavior, and is only needed to override another rule.

How do I reference multiple classes in CSS?

To specify multiple classes, separate the class names with a space, e.g. <span class="left important">. This allows you to combine several CSS classes for one HTML element. Naming rules: Must begin with a letter A-Z or a-z.


1 Answers

You can use selector grouping:

.foo, .list1 li {    background-color: red;  }  
like image 191
ChrisW Avatar answered Sep 22 '22 14:09

ChrisW