Coder Social home page Coder Social logo

Unpredicted CSS generated about gulp-ruby-sass HOT 4 CLOSED

thovo avatar thovo commented on June 11, 2024
Unpredicted CSS generated

from gulp-ruby-sass.

Comments (4)

UltCombo avatar UltCombo commented on June 11, 2024

That's how Sass works—@extend works globally across all selectors that will be part of your output file.

The good practice is usually to extend a placeholder selector that is only used in the given file. E.g.:

%input, input {
  // ...
}

select {
  @extend %input;
}

Maybe use classes instead of tag names, if you don't intend to apply the styling to all elements with the same name your application.

That said, Stack Overflow is a more suited place to ask technical questions.

from gulp-ruby-sass.

thovo avatar thovo commented on June 11, 2024

@UltCombo thank for your answer, because I just have 2 inputs and 2 selects there so I don't want to think about naming, that's why I used only tag names (I'll change now)

You are right that I should ask inside StackOverflow than here, it is just because I was typing the issue and just found that @extend in the same time so I asked here.

in my scss file, I let select extend only the input but later it extended also input[type="checkbox"], is it correct with sass?

from gulp-ruby-sass.

UltCombo avatar UltCombo commented on June 11, 2024

Yep, the @extend behavior is working as designed, but I agree it is rather non-intuitive quite often. The behavior is documented as follows:

@extend works by inserting the extending selector […] anywhere in the stylesheet that the extended selector […] appears.

So @extend works on partial and even nested selectors.
See also: What Nobody Told You About Sass’s @extend

from gulp-ruby-sass.

thovo avatar thovo commented on June 11, 2024

Many thanks, it is clear now!

from gulp-ruby-sass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.