1

Here is my CSS. How can i convert this code into LESS format.

.A .B h4, .A .B h4 a, .A .C h4, .A .C h4 a, .D h4, .D h4 a 
{
    color: #345e8a !important;
    display: inline-block;
    font-family: @font-family-sans-serif;
    font-size: 17px !important;
}
2
  • This is pretty simple and straight-forward mate. What have you tried? Please show us your attempt. Commented Jan 20, 2015 at 12:34
  • Also just in case we need to mention that it's already in Less format (no need to bulbulate selectors via nesting unless really necessary). Commented Jan 20, 2015 at 12:49

1 Answer 1

2

LESS is just a CSS preprocessor, it's your selector that could do with the improvement, we can combine that with LESS namespacing to have something like:

.A, .D
{
    h4, a
    {
        color: #345e8a !important;
        display: inline-block;
        font-family: @font-family-sans-serif;
        font-size: 17px !important;
    }
}

In the above I've simply stripped out your .A .C and .A .B selectors. If you need those, then you'll probably end up with an equally messy solution, but slightly more readable:

.A .B, .A .C, .D
{
    h4, a
    {
        color: #345e8a !important;
        display: inline-block;
        font-family: @font-family-sans-serif;
         font-size: 17px !important;
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

it's a bit incorrect, to produce the same CSS as in OP's example the nesting code would be something like this.
@seven-phases-max Yeah you're right, I assumed that the OP got his desired selector wrong, I took that .D h4, .D h4 a should have been .A .D h4, .A .D h4 a. I've changed it to remove the assumption so it better reflects the actual question :)

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.