Git Product home page Git Product logo

Comments (4)

JskB2 avatar JskB2 commented on May 22, 2024 1

Thanks a lot, Waldek!

from sp-dev-fx-webparts.

waldekmastykarz avatar waldekmastykarz commented on May 22, 2024

Is it possible to create a custom CSS file in the src folder and use it across the Web Part? For example, creating a standard set of Angular views and styling the HTML with that CSS?

Yes, you can include a regular .css file in your project and then in your code use require('./myfile.css') to load it inline in your web part. That way its contents would be embedded in the web part though so if you have multiple web parts and would like them to reuse the same CSS it might not be the perfect solution.

Is there any way of removing those suffixes?

Yes, you can wrap your classes in :global { ... }, like:

:global {
  .myclass {
  }
}

Everything inside :global will be left without suffix. Please note that it has the risk of conflicts of your classes with other classes that might be on the page. A thing that you could perhaps try would be to use the following construct:

.myWebPart {
  :global {
    .myClass {
    }
  }
}

On the top element of your web part you would use ${styles.myWebPart}. In your Angular template you would use regular CSS classes without any suffix. The difference in this approach is that the generated CSS would be like .myWebPart_5944ac05 .myClass which helps you isolate your styles from other styles available on the page.

from sp-dev-fx-webparts.

frankchen76 avatar frankchen76 commented on May 22, 2024

For your 'resx-strings' error, please check sp-module-loader loadCss broken in Drop 6 #286 . you need to add "@microsoft/sp-module-loader": "node_modules/@microsoft/sp-module-loader/dist/sp-module-loader.js", in your config.json if you need to use LoadCss().

from sp-dev-fx-webparts.

JskB2 avatar JskB2 commented on May 22, 2024

Thx much!

from sp-dev-fx-webparts.

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.