0

I wanted to load an external file named for //maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css in a specific div with its id named for registerForm.

Here are my code snippets as shown below.

html side

<div id="registerForm">
        <style scoped>
            @import "//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css";
        </style>
   ...
   </div>

This css file cannot implement in the specific div. It just covers all html code effects other divs.

I also tried this method shown below but nothing changed.

<style type="text/css" scoped="true">
            @import url('${pageContext.request.contextPath}/css/bootstrap.min.css');
        </style>


<script
    src="${pageContext.request.contextPath}/js/jquery.scoped.js"></script>

How can I do it?

S.N
  • 2,157
  • 3
  • 29
  • 78
  • Looks like there are callbacks for success and error states; you should at least have a callback for the error state to see if there's something there. Also, if you're posting someone else's code, you should at least give a link back to their site so they get credit... – Heretic Monkey May 07 '19 at 20:05
  • Duplicate of https://stackoverflow.com/questions/17667874/limit-scope-of-external-css-to-only-a-specific-element ? – dota2pro May 07 '19 at 20:08
  • dota2pro,Heretic Monkey I changed the post. – S.N May 07 '19 at 20:27
  • AFAIK no browser supports the `scoped` attribute and it shouldn't be used. – j08691 May 07 '19 at 20:31
  • This is a completely different question. [The `scoped` attribute was deprecated a while ago](https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement/scoped). See also [browser support for `scoped`](https://caniuse.com/#feat=style-scoped). AFAIK there is no way of pulling in an external file and applying to only one element in a document without rewriting the CSS. – Heretic Monkey May 07 '19 at 20:31
  • Possible duplicate of [Limit scope of external css to only a specific element?](https://stackoverflow.com/questions/17667874/limit-scope-of-external-css-to-only-a-specific-element) – Heretic Monkey May 07 '19 at 20:34
  • I looked many suggesstion to solve it out but I cannot reach the right result. – S.N May 07 '19 at 20:38

0 Answers0