I have an mvc 3 razor web application that uses several graphic components from a library.
I have set all the component in the library, I need to add a css file to the library but I dont know how to do it.
so how can I add a css file witch is a library ressource to a cshtml file.
I tried this but it doesnt work:
#section Styles {
<link href="#Url.Content("~/file.css")" />}
add the rel=stylesheet attribute to that link
Related
I have a spring boot project and I'm using TailwindCSS. The issue is, while putting
<link rel="stylesheet" type="text/css" th:href="#{~/css/main.css}" />
Works fine when I want to access the HTML file locally from my instance, the issue is I convert these HTMLs into PDFs using API2PDF service.
So, the service is unable to read the CSS and the HTML comes out to be without any styling.
How can I make sure the generated Tailwind CSS is sent along with the URL?
I would include the CSS within the HTML file using the <style> tag
I'm new to asp.net and have few questions.
I have a module with Index.cshtml along with _Partial1.cshtml and _Partial2.cshtml in the same folder.
Should I create individual external CSS file for each HTML file or use common CSS file per module?
If former, then does CSS file name of each partial also start with _?
Thanks in advance.
You can create individual CSS file for each HTML file and you can also write all css code in Index.cshtml.
There is a new feature called CSS Isolation in .Net6. CSS isolation simplifies an app’s CSS footprint by preventing dependencies on global styles and helps to avoid styling conflicts among components and libraries. CSS Isolation is enabled by default for ASP.NET Core 6.0 Projects.
So if you wanna create individual CSS file for each HTML file, You can use CSS isolation. Just create a css file called <ViewName>.cshtml.css, And it should be in the same folder as the view.
In your project, You can create CSS file called _Partial1.cshtml.css and _Partial2.cshtml.css, Then The project structure will become:
If you are using .Net5, You can try this code:
<link rel="stylesheet" href="~/css/P1.css">
<link rel="stylesheet" href="~/css/P2.css">
//......other code........
<div id="Pattial1">
#await Html.PartialAsync("/Views/Shared/_Partial1.cshtml")
</div>
<div id="Partial2">
#await Html.PartialAsync("/Views/Shared/_Partial2.cshtml")
</div>
CSS file
#Pattial1 h1{
color : red
}
//......
I have a simple flask application. It has flask-bootstrap installed and so I can access some CSS classes from there and my own style sheet in my static folder. However, I want to be able to add another stylesheet from a CDN in my index.html file.
I usually do something like place the following inside head tags.:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Is this possible? I don't think that using the
{{url_for('static' )}}
syntax would work here and I haven't found anything online that's describing what i'm doing (or I couldn't tell).
Yes, this is how I do it too. And then I link to my own stylesheet after the Bootstrap CDN.
Edit: and if you use a base template that is being extended by multiple templates for sub pages you can put the head tag in the base template so it precedes all templates.
I am using Bootstrap 3 Datepicker to use the DateTimePicker and I have downloaded the Nuget Package for this.
Now it is downloaded but I am unable to reference the files in my _Layout Shared view. I try to just drag and drop the file in there and then change the syntax to the razor style #Styles.Render("~/xxx/xxx")but everytime I try to drop it, nothing happens.
Is there something that I am missing. How do I reference these?
In my _Layouts for MVC, we just do it like this:
<link href="~/Xxx/xxx/xxx/xxx.css" rel="stylesheet" />
I don't believe it is necessary to use Razor syntax just to link a style sheet, but maybe if you want to render a bundle.
Okay in Nuget there is a .CSS version of Bootstrap v3 for the datetimepicker. once I downloaded that I was able to reference them in my _Layout view.
I have written an GWT app and a static Intro page that introduces the app. It is turning out to be convenient for the intro to be a separate .jsp page, rather than part of the app; however, I want the CSS styling to be the same for the app and the intro page. How do I include the same GWT CSS style for the static or .jsp page as for the GWT app?
just include it like a standard webpage like
<link rel="stylesheet" type="text/css" href="{Path to css here}"/>
For instance using the Clean css provided by gwt, defined in projectname.gwt.xml:
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
Your css will be stored in:
/projectname/gwt/clean/clean.css
Is that what you mean?