且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将材料样式添加到ASP.NET MVC Web应用程序?

更新时间:2023-02-16 23:06:55

因此,我能找到的***解决方案是添加Material-UI and a few others, but they don't seem to work 100%. I can't get any of the checkboxes and stuff to work.

I "initialized" the matieral-ui in _Layout.cshtml as so:

<link rel="stylesheet"
      href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<script type="text/javascript"
        src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js">
</script>

And the styles are applied, but I can't change the default color (Which seems to be green), floating labels are weird, and datepickers still have the native .net appearance.

Labels look like this:

And date pickers look like this:

But they both should look like this:

Can Material-UI not do this? Is so, how do I do it in ASP.NET MVC? I'm super new to .NET, so please forgive my naivety if the answer is obvious.

So the best solution I could find is to add materialize-css via npm and then copy the materialize.min.css and js files into a directory in my wwwroot folder and refrence them both in the _layout.cshtml.