Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Overriding default CSS in moduleOverriding default CSS in module
Previous
 
Next
New Post
4/19/2011 7:39 AM
 
Hi,

I'm writing my custom module. How do I set it up, so that it doesn't inherit CSS styles form the DNN skin?
 
New Post
4/19/2011 1:03 PM
 
The Module.css file loads first, so anything after it has the ability to override it. That being said you could try the !important option in CSS to try to stop the overriding from occuring.

Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
4/21/2011 8:31 AM
 
Hi Mark,

The best way to make sure that your module.css styles don't inherit from the dnn skin or other css included on the page is to provide the proper amount of specificity on your markup and specifying all of the css attributes on your styles that you don't want to be overridden. Just do a google search on 'css specificity' and you'll see what I'm talking about.

For instance you could create a div in your module surrounding your module content with your module's name as the class such as <div class="mymodule"> more content here </div> and then in your css make sure you use mymodule as part of the selectors such as .mymodule span { font-size: 12px; color: #ff0000 } etc. You could also use an id instead of a classname but I'd guard against that because your module could be added to the page more than once.

Because the selector .mymodule span is more specific then just span, the css won't cascade from the other css and the more specific you can make it the better. There are specificity rules that the browsers use to determine how specific they are. A good quick reference can be found here.

Cheers



Richard Edwards
www.dnnstuff.com
Quality DotNetNuke Modules, Unrivaled Support (since 2004)
All 6 modules for as low as $49
 
New Post
4/26/2011 11:06 AM
 
I would suggest the ' !important ' make sure that this has to be used after the default css is loaded.
 
New Post
4/26/2011 12:27 PM
 
I would strongly oppose the use of !important in your css if you can avoid it. Have a read of this article, http://www.smashingmagazine.com/2010/11/02/the-important-css-declaration-how-and-when-to-use-it/



Richard Edwards
www.dnnstuff.com
Quality DotNetNuke Modules, Unrivaled Support (since 2004)
All 6 modules for as low as $49
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Overriding default CSS in moduleOverriding default CSS in module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out