Is there a way to have CSS in an html widget only affect the elements contained therein?

 I've created an html widget with some custom CSS that is affecting the "label" element in the Admin tools.

Here's the sample code which is something I may use to create a custom navigation and help users find specific content.

Note that I have the labels styled with a background color, when you hover over the label.

Here's what's happening in the Admin tools, as a result ➞

Parents
  • I'm having this issue again and am wondering if there is a generic and quick way to make it so all styles/scripts/etc. used in an html widget ONLY affect the content of that widget? Can I wrap all of the styles in some single container that is identified to encapsulate all widget content only?

    I'm not sure if I'm asking this the right way. but the bottom line is that I'd like to know the quickest and easiest way to make it so all code on an html widget only affects the content of that single widget and not the rest of the page.

    Any thoughts . , ?

  • Didn't I say take what I say on CSS with caution! Wink

    Is it because you're including...

    html,

    body {

      width: 100%;

      margin: 0;

      padding: 0;

      font-family: helvetica;

      font-size: 12px;

    }

    When you only want a div...

    div.customstyling {

      width: 100%;

      margin: 0;

      padding: 0;

      font-family: helvetica;

      font-size: 12px;

    }

    ...but you need a wrapping div in the HTML...

    <div class="customstyling">

    /* *** ALL YOUR EXISTING HTML INSIDE THIS *** */

    </div>

    Try.  See.  No promises!

Reply Children
No Data