2

I am trying to add CSS in <style> tag in Control Display template. But its not applying that CSS. Its taking inline CSS but not taking when adding inside <Style>Tag

PS: New to display tempaltes.

2 Answers 2

2

Did you check in css file to major version (1.0)? You need to add that line $includeCSS inside <script> not <style>

<script>
$includeCSS(this.url, "~sitecollection/Style Library/Slider/css/example.css");
</script>

Link: http://www.jasperoosterveld.com/2014/08/how-to-reference-your-custom-css-within-a-search-display-template/

1
  • Can we add css on html page directly without referring it. With <Style> Tag. The way we generally do with HTML page. <Style> h{font-size:30px}</style> Feb 2, 2016 at 8:54
0

move css content into a separate file and reference it in script tag

more information here

3
  • $includeCSS(this.url,"~sitecollection/style library/Slider/css/example.css"); is not working for me. Not sure why. Added CSS to style library. Feb 2, 2016 at 7:18
  • Onpage will also work for me But I am able to give on page also. Feb 2, 2016 at 7:23
  • did you get any error in the developer tools console? with default settings of style library, if css file is not published, you would get 404 not found error.
    – Ali
    Feb 2, 2016 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.