inside page css cancels effects of dotless reference in asp .net mvc - css

When I don't use inner page style, dotless style* works perfectly. But, when I use inner page style(nothing else changed), inner page style works but dotless style doesn't work anymore. Is this a bug, or is there a solution?
*What I mean with "dotless style" is the style of .less file referenced by page.
Inner page style:
<style type="text/css">
.detailRow {
border: 1px solid burlywood;
}
</style>
Dotless file reference:
<link href="#Url.Content("~/_Stil/Ortak/TableFormat.less")" rel="stylesheet" type="text/css" />

Since the css in the referenced dotless file is working fine without the on page styling and then after adding the style tag it stops to work I have to make a few assumptions..
Since you say that only one of them can work at the same time I assume that they are overriding each other.
Like if you have the exact same css class in your less file and then add a style tag on your page you might override the css class in the file (depending on the markup in the file ofc). This might give the illusion that the css class in the less file have stopped working.
I suggest that you scope the css class in the less file with an id or something like that to give it more specificity and see what happens. Else you should show some content from the less file and some HTML markup of the page.

Related

Laravel overriding bootstrap template

So I got my custom app.css in my project and I'm using bootstrap template. Now when I create new button style for example in app.css it's accessible everywhere (on every page since I got master template and other pages are extending it) but when I override bootstrap theme in app.css it's not working. When I use same code to override bootstrap on top of the page using <style> tags it's working. app.css is included properly and after bootstrap.css so any idea what I'm doing wrong ?
Try a cache refresh, for me in Chrome, I use Ctrl+Shift+R.
If this doesn't produce any results, use the inbuilt inspectors on Chrome or Firefox to view the attached properties to the element you are editing. If the app.css is overriding the bootstrap.css, you will see something like the below image, showing the app.css is above the skin-purple.min.css meaning the app.css was the latest to be loaded.
I would say that there is a hierarchy, try to include the bootstrap.css after the app.css, you could also give those css attribute an !important like so:
#bla {
display:none !important
}
But that is not a good practice I think, it may be ok if you do not override alot of the bootstrap.css
You could also try this:
http://bootstrap-live-customizer.com/
to customize your bootstrap.
It most probably is a style precedence issue. I found this article very useful to at least understand what goes on with style precedence and what specificity is.
In your very case it may be helpful to simply use a class selector such as
.mybutton button{
color: blue;
font-size: inherit;
...
}
and give your buttons the attribute class="mybutton". In the class definition you may freely override whatever you want and also let other properties be inherited from Bootstrap.
There is also the !important rule. However, it is usually referred to as a bad practice, since it breaks the normal cascading rules and makes debugging an incredibly painful task.

Internal style sheet being over riden by external css declared earlier in html doc

Im playing around with the front end of a site using the new bootstrap 3.0 and im fine tuning things by irritating in firebug, but there is something odd that i keep noticing
even though my <head> is layed out like this
<link rel="stylesheet" href="bootstrap.css">
<style>
td {padding:0px;}
<style>
With the external css being declared before the internal (which im only using during development) the external styles are still over riding them.
To get the padding:0px; to work i need to set it as padding:0px !important;
Any ideas why this is.. i thought that the last declared peice of css would always override conflicting previously declared css.
CSS precedence is about !important, origin (user vs browser), specificity and then order. Here is a good explanation.

Why is my CSS file overridden with another stylesheet?

I developed an application, and I used header and footer from another app. I created a separate style sheet for my app, called TestStyleapp.css. When I run my new application, the stylesheet I used from the other app is overriding my new CSS file.
Is there a way to include/reference the Teststyleapp.css (I tried calling it last) other than using !important in front of all the elements in teststyleapp.css?
When I use FireBug, I do not see Teststyleapp.CSS at all.
Even if it is LAST, if it is NOT more SPECIFIC (the other page items are more specific) it will not override what is above it in the stack.
Example:
div .myclass (background-color: red);
other (yours has)
.myclass(background-color:green);
you still see red.
<link rel="stylesheet" href="TestStyleapp.css" type="text/css" media="screen" />
It should be linked as such, between the head tags. Make sure the case is correct. I like using all lowercase and _ as a word separator. Just my personal style.
First, get the .css file to show in the NET tab in Firebug and we'll take it from there.

Need help with Telerik RADEditor CSS issues

<telerik:RadEditor ToolbarMode="Default"
ID="editor1" runat="server" EnableEmbeddedBaseStylesheet="true">
</telerik:RadEditor>
The editor's using Default skin. When I made changes to Editor.Default.CSS file they didn't reflect on my page, but when I type the following I can see the changes:
<link href="Skins/Default/Editor.Default.css" rel="stylesheet" type="text/css" />
<link href="Skins/Default/Window.Default.css" rel="stylesheet" type="text/css" />
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadEditor ToolbarMode="Default"
ID="editor1" Skin="Default" runat="server" EnableEmbeddedSkins="true">
</telerik:RadEditor>
Do I have to create a custom Skin file for the changes to reflect? I don't want to because the editor has been used in many files and now linking new custom CSS file in each and every .aspx file will be such a pain. I just want this to be added in the Skin:
body
{
background-image:none;
background-color:White;
}
What this does is that it makes the background color of the content area white. Earlier the content area of the Editor was inheriting background-image property of the Master Page's body tag. Another funny issue is that the Font styles too are inheriting Master Page's properties only, like Heading 2 in the Editor's drop down list has got a background color when I want it to be simple.
So is making custom skin CSS file the only solution? How do I get the changes to reflect through the Default CSS file only? I don't want to create a custom class. Why didn't the changes reflect?
If you do not want the editor to inherit the CSS from the main page, you should tell it which CSS classes are to be loaded in the content area (iframe). See the external CSS help article and probably the CSS dropdown article as well. Finally, there is a separate page for content area CSS troubleshooting - content area appearance problems
Make sure your body background-color is not overwritten in the Window.Default.css. Always the last entry in a CSS file or a subsequent file takes precedence over the one before. Try going for background-color:white !important;.
Adding !important after any CSS rule will make it just that and override any precedence.
As for why the changes didn't reflect: Check which styles the Telerik control is actually using. Check the Source of the page and check the references CSS files whether they have your added properties - maybe there are some other CSS files creeping around in some cache?
Your tool of choice to check the styles for a specific element might be the Internet Explorer (if you're using IE) Developer Toolbar - just hit F12 and select the Telerik Editor with the little arrow and you will see all associated styles and where they came from.
One solution that worked for me was to set these properties on the editor:
ContentAreaMode="Div"
CssClass="wysiwygeditor"
then in CSS you can override what you need
.wysiwygeditor { background-color: white; background-image: none; }
It would be nice if Telerik would expose a property to set a class on the body element when using ContentAreaMode=Iframe instead of Div, both CKeditor and TinyMCE support a property like that and it makes it possible to easily remove the unwanted body styles while still supporting most of the page CSS in the editor.
You can edit an xml config file (in my case it is named ConfigDefault.xml).
In the <configuration/> node you can add something like the following to load the css of your choice to apply to the content (html document) that is loaded within the iframe:
<configuration>
<property name="CssFiles">one.css,two.css</property>
...more items
</configuration>
So if you need one.css for your regular site css, then two.css can perform the override to remove the background image / change the background colour.

How do I include static html in an asp.net mvc app that doesn't use the system css, but it's own styling?

I am using ASP.NET MVC 2 & C#.
I want to include/embed an html page (raw text & styling; no forms) in one of my views as is without my own css styling (read: The site.css styles for the ASP.NET MVC 2 application itself) affecting it. I can access the page statically and open it in a new window and it retains it's styling; however, if I do:
<asp:Content ID="loginContent" ContentPlaceHolderID="MainContent" runat="server">
<!--#include virtual="~\Static\Instructions.htm" -->
</asp:Content>
The styling from the html & the site.css in the web application seem to get merged.
I've added the following ignore route entries as well:
routes.IgnoreRoute("{resource}.html/{*pathInfo}");
I also tried making a partial view control with the raw html in it and rendering that here. That gives the exact same results as this.
Thoughts?
When you include a file with the code above, it's like appending the entire data into the original file, as if there was no include at all. Doing it this way, you will inherit all relative JavaScript and CSS that is on the parent file.
The only way you can solve this is by creating a wrapper around your main content and setting all the CSS elements to affect that wrapper only. Aside from that, the only other option is setting a CSS style for your appended file with specific IDs or clean up your current CSS to be more specific.
One final method, if you have CSS affecting the included file (I assume from your OP, you have CSS styling inside the file itself), you can set !important to them so that they overwrite any other CSS classes affecting them.
You could add a wrapper <div id="embed"> around your embedded content and then use #embed in your site.css to override the styles you don't want applied.
p {
color: red;
}
#embed p {
color: blue;
}
I can only suggest to do so as Pat and lighthazard said.
There's no routing problem.
Try to change your perspective to the rendered html code.
If you have a page, and there's an area, that should be in other (none) styles. then you must mark this area either by a css class, if there are many areas, or if this is the only one per page an css id.
By the way, not to style ist not possible in html. At least the browser stylesheets will define the output.
Here's en interesting Question, i hope this will help.
CSS Reset, default styles for common elements

Resources