3

I'm loading emails (via gmail's api) using Angular:

<div class="email-body">
  <div compile-html data-html="thread.message.body"></div>
</div>

When I do so, the loaded emails bring with them css styling that affect the css of the whole site.

For example, my css:

.container {
  width: 80%;
}

But an email (once loaded) brings the following css:

.container {
  width: 20% !important;
}

The css for .container gets overridden by the newly loaded css. Is there a way I could contain the imported css within a div (email-body)?

Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
Daniel Falabella
  • 578
  • 4
  • 13

1 Answers1

1

This could might not be the fastest way, but gets the job done without iframes (using javascript and jquery):

  $('.email-body').find('*').each(function () {
    if ($(this).css("width")) {
      var setWidth = $(this).css("width");

      //clearing width value
      setWidth = setWidth.replace(/[^0-9]/g, '');

      $(this).css("width", NEW WIDTH VALUE HERE);
    }
  })

If you are using Angular, you might want to wrap this in a $timeout.

Daniel Falabella
  • 578
  • 4
  • 13