1

I currently have this code :

input[type=text] {
    background:transparent top center no-repeat;
    height:30px;
    font-size:13px;
    color:@greyBlue;
    padding:0 10px;
    border:none;
    &.long {
        background-image:url("/img/input_long.png");
        width:214px;
    }
    &.medium {
        background-image:url("/img/input_medium.png");
        width:96px;
    }
    &.short {
        background-image:url("/img/input_short.png");
        width:55px;
    }
}

Do you know if I can simplify that by just changing the filename part with a variable? Something like this :

input[type=text] {
    @input = "";
    background-image:url("/img/input_@{input}.png");

    &.long {
        @input = "long";
    }
}

If course this doesn't work, but if you have any idea about a functionnal way... Thanks a lot!

1 Answer 1

1

create a mixin

.bgImg(@input) {
     background-image:url("/img/input_@{input}.png");
}

and call it accordingly:

&.long {
    .bgImg("long");
}
Sign up to request clarification or add additional context in comments.

Comments

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.