简体   繁体   中英

Template page css overriding my original css

I have template page template.html with css, css includes body{ font-family:'Arial'}. This page included in my application using 'ng-include' when page renders my applications fonts get changed. can i prevent my application's css to be overridden my template page ..?

Simply put your Template.html in a div and you can use inline css or css in that page near that div.

you can do like this

<div style="font-family:'YourNewFontHere'">

// include your html page here 

</div>

I assume it is inline styles in the template.html? One possibility would be to increase the strength of you css rules in your normal page. For example, we assume you have a wrapper div (or s.th. similar) around your content, then you could set:

body .wrapper {
  whatever styles you want
}

This would override the style from template.html.

You could also add !important to your normal css rules you do not want to be overwritten.

Best of all would be to remove any style-tags from the template.html - why do you style this page inline?

尝试放置在html文件的标题上。

<style> body { font-family: 'Arial'; } </style>

You will need to increase the specificity of your application's CSS selector for the <body> tag. Which shouldn't be too hard since your template is overriding your application's CSS with a simple selector of body { ... } .

Couple of ideas.

  1. For your application's <body> selection change from body { ... } to html body { ... } .
  2. Add a class to the <body> tag, <body class="site"> . Then change body { ... } to .site { ... } .
  3. Remove the body { ... } from the template.

Template page is HTML string like email body which has its own css. when include this in my application i don't know what css that page have because its generated dynamically. After page rendered i come to know that my css is overridden

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM