Search code examples
asp.netsingle-page-applicationdurandalhottowel

Disable Durandal inline styling


Durandal appears to automatically add the following inline styling to the div elements wrapping its data-views:

style="margin-left: 0px; margin-right: 0px; opacity: 1; display: block;"

This occurs in both the Durandal and John Papa Hot Towel ASP.NET SPA templates that make use of Durandal.

This inline styling is overriding my external stylesheet, so I need to disable this behavior. I'm assuming this is being injected by one of the JavaScript files, but I can't for the life of me seem to figure out where.

Anyone know how to prevent this inline styling from being added?


Solution

  • This is being set by the "entrance" transition (durandal/transitions/entrance.js). Looks like the final end point for the transition is those values, and they're not being removed when transition is complete.

    You can avoid this entirely by not using the transition. This will take a couple of steps:

    1. In main.js, modify your app.setRoot() call to remove the 'entrance' parameter. This will prevent the styling settings from being added to the shell container
    2. In shell.html, remove the transition setting from the compose binding. This will prevent the styling settings from being added to the individual views.

    The other possibility is to create your own transition that is more compatible with your CSS requirements.