一、下载adminlte

官网:https://almsaeedstudio.com/

github:https://github.com/almasaeed2010/AdminLTE/

二、引用的基本解说

1、meta没的说
2、引入bootstrap
3、引入字体库,肯定用得到,下载到本地放在plugins下也可以
4、adminLTE子什么的文件肯定需要
5、皮肤skin,可以引入_all...,但是如果只需要一个皮肤的话,比如只需要蓝色,直接引入skin-blue就行,毕竟越简越好
6、兼容IE8的两个js文件
7、jquery没的说
8、fastclick,触摸设备快速点击体验,不想兼容手机可以去掉
9、slimscroll,菜单和页面中的滚动条样式,放上去毕竟好看嘛。(看一下不加的效果,不好看吧)

下面是引用的原代码,可是用starter.htm中查看,对应上面的进行查看

<meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AdminLTE 2 | Starter</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.6 --> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"> <!-- Ionicons --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css"> <!-- Theme style --> <link rel="stylesheet" href="dist/css/AdminLTE.min.css"> <!-- AdminLTE Skins. We have chosen the skin-blue for this starter page. However, you can choose any other skin. Make sure you apply the skin class to the body tag so the changes take effect. <link rel="stylesheet" href="dist/css/skins/skin-blue.min.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head>
二。adminlte文件夹说明

dminLTE是基于bootstrap3的前端框架,并且将bootstrap3进行修改来适应自身的样式。

adminLTE除了可以使用bootstrap3的大多数样式之外,自身也提供了一些非常实用的样式包装,并且在样式演示中已经基本罗列出来了。

adminLTE的js是基于jquery2。

adminLTE的插件中使用的基本都是bootstrap和jquery的插件。

想开始使用adminLTE样式,只需要在项目演示中按F12打开调试窗口,使用箭头选中控件,复制粘贴即可,如图

adminLTE提供了基础模板页面starter.html,再此基础上做开发会快速很多:

一、body样式:

1、类hold-transition是对IE的transition做了一些修复,在body引用即可,没什么深层含义

2、皮肤的样式

侧边栏默认是暗色。

skin-blue中的 blue 蓝 修改的是标题的颜色,

只有指定第二个颜色的时候才会改变侧边栏颜色,

如skin-blue-light中第二个颜色表示侧边栏为亮色。

adminLTE提供的默认皮肤颜色有:

蓝 skin-blue skin-blue-light

黄 skin-yellow skin-yellow-light

绿 skin-green skin-green-light

紫 skin-purple skin-purple-light

skin-red  skin-red-light

字体黑,皮肤白  skin-black skin-black-light

默认侧边栏隐藏,标题不移动

<body class="hold-transition skin-blue">

Fixed 只是为了固定导航栏

layout-boxed    只是将页面包含在一个固定盒子中,max-width最大宽度: 1250px;

当fixed布局和layout-boxed布局一起使用时,layout-boxed样式不会生效,只有fixed布局会生效

sidebar-collapse  让侧边栏默认是隐藏状态

layout-top-nav   将导航栏设置为单纯的导航菜单,不使用侧边栏

sidebar-mini 让侧边栏和左侧导航一起折叠,并且最小化是小图标。

sidebar-mini一般和Fixed layout-boxed sidebar-collapse 一起配合使用,因为layout-top-nav布局的目的就是不要侧边栏

<body class="hold-transition skin-blue sidebar-mini">

二、body构造
 <div class="wrapper">
    <!-- 顶部导航栏 -->
    <header class="main-header">
    </header>
    <!-- 左侧菜单栏 -->
    <aside class="main-sidebar">
    </aside>
    <!-- 中间内容 -->
    <div class="content-wrapper">
    <!-- 底部标注 -->
    <footer class="main-footer">
    </footer>
    <!-- 右侧菜单栏 -->
    <aside class="control-sidebar control-sidebar-dark">
    </aside>
    <!-- 右侧菜单栏的样式,底部距离为0等 -->
    <div class="control-sidebar-bg"></div>

  四。在MVC5项目中加入adminlte

1.我将adminlte全部复制进 Content文件夹下

2.在MVC5项目中将adminlte文件夹及文件包含进项目。

六.bundles相关的JS和CSS

1.我将引用二个远程CSS下载下来到本地的CSS夹中,我是放在bootstrap/css/下面的,结果这个方法是错误的,他的远程的二个主要是字体图标的引用,必须远程,否得你得更改内容或是下下来。

  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">

对应看看index.htm和starter的源码。对比看看引用,这index比satrt是多太多了。

所我做成了二个bundles.

bundles.Add(new StyleBundle("~/Content/adminlte/bootstrap/css").Include(
					  "~/Content/adminlte/bootstrap/css/bootstrap.min.css",
									"~/Content/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.css",
						   "~/Content/adminlte/dist/css/AdminLTE.min.css",
							"~/Content/adminlte/dist/css/skins/skin-blue.min.css"));
			bundles.Add(new ScriptBundle("~/bundles/adminlte").Include(
				"~/Content/adminlte/plugins/jQuery/jquery-2.2.3.min.js",
			"~/Content/adminlte/bootstrap/js/bootstrap.min.js",
						"~/Content/adminlte/dist/js/app.min.js"));
			bundles.Add(new ScriptBundle("~/bundles/adminlte/js").Include(
		"~/Content/adminlte/dist/js/raphael-min.js",
				"~/Content/adminlte/plugins/morris/morris.min.js",
				"~/Content/adminlte/plugins/sparkline/jquery.sparkline.min.js",
				"~/Content/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js",
				"~/Content/adminlte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js",
				"~/Content/adminlte/plugins/knob/jquery.knob.js",
					"~/Content/adminlte/dist/js/moment.min.js",
						"~/Content/adminlte/plugins/daterangepicker/daterangepicker.js",
							"~/Content/adminlte/plugins/datepicker/bootstrap-datepicker.js",
								"~/Content/adminlte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js",
	"~/Content/adminlte/plugins/slimScroll/jquery.slimscroll.min.js",
		"~/Content/adminlte/plugins/fastclick/fastclick.js",
			"~/Content/adminlte/dist/js/pages/dashboard.js",
				"~/Content/adminlte/dist/js/demo.js"));
			bundles.Add(new StyleBundle("~/Content/adminlte/css").Include(
				  "~/Content/adminlte/plugins/iCheck/flat/blue.css",
					"~/Content/adminlte/plugins/morris/morris.css",
					  "~/Content/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.css",
								"~/Content/adminlte/plugins/datepicker/datepicker3.css",
					   "~/Content/adminlte/plugins/daterangepicker/daterangepicker.css",
						"~/Content/adminlte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"));

  这样做的目的是:可以分别引用JS和CSS.

现在我们新建一个布局页,取名为_AdminLayout

 注意,我布局而中,引用了1个分布局,一个是菜单,同时在中间引入了内容标签

<!DOCTYPE html>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>@ViewBag.Title </title>
	@Styles.Render("~/Content/adminlte/bootstrap/css")
	@Styles.Render("~/Content/adminlte/css")
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
	<!-- Ionicons -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body   class="hold-transition skin-blue  layout-boxed  sidebar-mini">
	<!-- Site wrapper -->
	<div class="wrapper">
		<!-- 顶部导航栏 -->
		<header class="main-header">
			<!-- Logo -->
			<a href="#" class="logo">
				<!-- mini logo for sidebar mini 50x50 pixels -->
				<span class="logo-mini"><b>M</b>Oa</span>
				<!-- logo for regular state and mobile devices -->
				<span class="logo-lg"><b>Mydhh</b>Oa</span>
			<!-- Header Navbar -->
			<nav class="navbar navbar-static-top" role="navigation">
				<!-- Sidebar toggle button-->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
					<span class="sr-only">Toggle navigation</span>
				<!-- Navbar Right Menu -->
				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">
						<!-- Messages: style can be found in dropdown.less 就是邮件图标那个-->
						<li class="dropdown messages-menu">
							<!-- Menu toggle button -->
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								<i class="fa fa-envelope-o"></i>
								<span class="label label-success">4</span>
							<ul class="dropdown-menu">
								<li class="header">You have 4 messages</li>
									<!-- inner menu: contains the messages -->
									<ul class="menu">
											<!-- start message -->
											<a href="#">
												<div class="pull-left">
													<!-- User Image -->
													<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
												<!-- Message title and timestamp -->
													Support Team
													<small><i class="fa fa-clock-o"></i> 5 mins</small>
												<!-- The message -->
												<p>Why not buy a new awesome theme?</p>
										<!-- end message -->
									<!-- /.menu -->
								<li class="footer"><a href="#">See All Messages</a></li>
						<!-- /.messages-menu -->
						<!-- Notifications Menu -->
						<li class="dropdown notifications-menu">
							<!-- Menu toggle button -->
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								<i class="fa fa-bell-o"></i>
								<span class="label label-warning">10</span>
							<ul class="dropdown-menu">
								<li class="header">You have 10 notifications</li>
									<!-- Inner Menu: contains the notifications  喇叭图标那个-->
									<ul class="menu">
											<!-- start notification -->
											<a href="#">
												<i class="fa fa-users text-aqua"></i> 5 new members joined today
										<!-- end notification -->
								<li class="footer"><a href="#">View all</a></li>
						<!-- end-Notifications Menu -->
						<!-- Tasks Menu 旗子任务图标 -->
						<li class="dropdown tasks-menu">
							<!-- Menu Toggle Button -->
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								<i class="fa fa-flag-o"></i>
								<span class="label label-danger">9</span>
							<ul class="dropdown-menu">
								<li class="header">You have 9 tasks</li>
									<!-- Inner menu: contains the tasks -->
									<ul class="menu">
											<!-- Task item -->
											<a href="#">
												<!-- Task title and progress text -->
													Design some buttons
													<small class="pull-right">20%</small>
												<!-- The progress bar -->
												<div class="progress xs">
													<!-- Change the css width attribute to simulate progress -->
													<div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
														<span class="sr-only">20% Complete</span>
										<!-- end task item -->
								<li class="footer">
									<a href="#">View all tasks</a>
						<!-- end task item -->
						<!-- User Account Menu -->
						<li class="dropdown user user-menu">
							<!-- Menu Toggle Button -->
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								<!-- The user image in the navbar-->
								<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
								<!-- hidden-xs hides the username on small devices so only the image appears. -->
								<span class="hidden-xs">Alexander Pierce</span>
							<ul class="dropdown-menu">
								<!-- The user image in the menu -->
								<li class="user-header">
									<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
										Alexander Pierce - Web Developer
										<small>Member since Nov. 2012</small>
								<!-- Menu Body -->
								<li class="user-body">
									<div class="row">
										<div class="col-xs-4 text-center">
											<a href="#">Followers</a>
										<div class="col-xs-4 text-center">
											<a href="#">Sales</a>
										<div class="col-xs-4 text-center">
											<a href="#">Friends</a>
									<!-- /.row -->
								<!-- Menu Footer-->
								<li class="user-footer">
									<div class="pull-left">
										<a href="#" class="btn btn-default btn-flat">Profile</a>
									<div class="pull-right">
										<a href="#" class="btn btn-default btn-flat">Sign out</a>
						<!--end User Account Menu -->
						<!-- Control Sidebar Toggle Button 右侧菜单-->
							<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
				<!-- /div wrapper -->
		</header>
		<!-- end header 头部结束  -->
		<!-- 大侧菜单布局 Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar">
			@Html.Partial("Menu")
		<!-- /.sidebar -->
		<!--中间内容 Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			@RenderBody()
		<!--end 中间内容 Content Wrapper. Contains page content -->
		<!-- Main Footer -->
		<footer class="main-footer">
			<!-- To the right -->
			<div class="pull-right hidden-xs">
				Anything you want
			<!-- Default to the left -->
		</footer>
		<!-- end Footer -->
		<!-- Control Sidebar -->
		<aside class="control-sidebar control-sidebar-dark">
			<!-- Create the tabs -->
			<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
				<li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
				<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
			<!-- Tab panes -->
			<div class="tab-content">
				<!-- Home tab content -->
				<div class="tab-pane active" id="control-sidebar-home-tab">
					<h3 class="control-sidebar-heading">Recent Activity</h3>
					<ul class="control-sidebar-menu">
							<a href="javascript:;">
								<i class="menu-icon fa fa-birthday-cake bg-red"></i>
								<div class="menu-info">
									<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
									<p>Will be 23 on April 24th</p>
					<!-- /.control-sidebar-menu -->
					<h3 class="control-sidebar-heading">Tasks Progress</h3>
					<ul class="control-sidebar-menu">
							<a href="javascript:;">
								<h4 class="control-sidebar-subheading">
									Custom Template Design
									<span class="pull-right-container">
										<span class="label label-danger pull-right">70%</span>
									</span>
								<div class="progress progress-xxs">
									<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
					<!-- /.control-sidebar-menu -->
				<!-- end 右侧菜单/.control-sidebar-menu -->
				<!-- /.tab-pane -->
				<!-- Stats tab content -->
				<div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
				<!-- /.tab-pane -->
				<!-- Settings tab content -->
				<div class="tab-pane" id="control-sidebar-settings-tab">
					<form method="post">
						<h3 class="control-sidebar-heading">General Settings</h3>
						<div class="form-group">
							<label class="control-sidebar-subheading">
								Report panel usage
								<input type="checkbox" class="pull-right" checked>
							</label>
								Some information about this general settings option
						<!-- /.form-group -->
					</form>
				<!-- /.tab-pane -->
		</aside>
		<!-- end 右侧菜单 /.control-sidebar -->
		<!-- Add the sidebar's background. This div must be placed
	immediately after the control sidebar -->
		<div class="control-sidebar-bg"></div>
			@Scripts.Render("~/bundles/adminlte")
			@Scripts.Render("~/bundles/adminlte/js")
			@RenderSection("scripts", required: false)
			<script src="~/Scripts/jquery.validate.js"></script>
			<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
</body>
</html>

然后菜单页的布局为:

  <!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
	<!-- Sidebar user panel (optional) -->
	<div class="user-panel">
		<div class="pull-left image">
			<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
		<div class="pull-left info">
			<p>Alexander Pierce</p>
			<!-- Status -->
			<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
	<!-- search form (Optional) -->
	<form action="#" method="get" class="sidebar-form">
		<div class="input-group">
			<input type="text" name="q" class="form-control" placeholder="Search...">
			<span class="input-group-btn">
				<button type="submit" name="search" id="search-btn" class="btn btn-flat">
					<i class="fa fa-search"></i>
				</button>
			</span>
	</form>
	<!-- /.search form -->
	<!-- Sidebar Menu -->
	<ul class="sidebar-menu">
		<li class="header">HEADER</li>
		<!-- Optionally, you can add icons to the links -->
		<li class="active"><a href="~/User/Admin"><i class="fa fa-link"></i> <span>Link</span></a></li>
		<li><a href="~/User/List"><i class="fa fa-link"></i> <span>Another Link</span></a></li>
		<li class="treeview">
			<a href="#">
				<i class="fa fa-link"></i> <span>Multilevel</span>
				<span class="pull-right-container">
					<i class="fa fa-angle-left pull-right"></i>
				</span>
			<ul class="treeview-menu">
				<li><a href="#">Link in level 2</a></li>
				<li><a href="#">Link in level 2</a></li>
	<!-- /.sidebar-menu -->
</section>

然后我选了一个用户列表作为测试,我在中间加入了布局使用admin布局。

@model IEnumerable<jsdhh2.Models.User>
	ViewBag.Title = "List";
	Layout = "~/Views/Shared/_AdminLayout.cshtml";
	<!-- Content Header (Page header) -->
	<section class="content-header">
			<small>针对所有的用户清单进行操作</small>
		<ol class="breadcrumb">
			<li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
			<li class="active">Here</li>
	</section>
	<!--end Content Header (Page header) -->
	<!-- Main content -->
	<section class="content">
		<div class="ibox float-e-margins">
			<div class="ibox-content">
				<div class="form-group">
					<a class="btn btn-primary" href="/User/Add">添加</a>
					<button id="btnEdit" type="button" class="btn btn-info " onclick="editModel()"><i class="fa fa-pencil"></i> 编辑</button>
					<button id="btnDel" type="button" class="btn btn-danger " onclick="delData()">
						<i class="fa fa-remove"></i>  <span class="bold">删除</span>
					</button>
					<button id="btnSetRole" type="button" class="btn btn-info "><i class="fa fa-user"></i> 角色授权</button>
					<button id="btnResetPwd" class="btn btn-warning"><i class="fa fa-undo"></i> 重置密码</button>
				<div class="form-group">
					<div class="input-group col-md-4">
						<input id="txtSearchKey" type="text" class="input form-control" placeholder="搜索关键字" />
						<span class="input-group-btn ">
							<button id="btnSearch" class="btn btn btn-primary" type="button"> <i class="fa fa-search"></i> 搜索</button>
						</span>
				<div class="jqGrid_wrapper">
					<table id="table_list"></table>
					<div id="pager_list"></div>
<table class="table">
	<thead>
			<th>用户名</th>
			<th>电子邮件</th>
			<th>生日</th>
			<th>QQ号码</th>
			<th>电话号码</th><th>创建时间</th>
	</thead>
	<tbody>
		@foreach (var user in Model)
				<td>@Html.DisplayFor(m => user.UserName)</td>
				<td>@Html.DisplayFor(m => user.Email)</td>
				<td>@Html.DisplayFor(m => user.BirthDate, "DateTimeTemplate")</td>
				<td>@Html.DisplayFor(m => user.QQ)</td>
				<td>@Html.DisplayFor(m => user.PhoneNumber)</td>
				<td>@Html.DisplayFor(m => user.CreateTime, "DateTimeTemplate") </td>
					@Html.ActionLink("详情", "DetailsList", new { id = user.Id }, new { @class = "btn btn-info" })
					@Html.ActionLink("编辑", "Edit", new { id = user.Id },new { @class= "btn btn-success" })
					@Html.ActionLink("删除", "Del", new { id = user.Id }, new { @class = "btn btn-warning" })
					@Html.ActionLink("重置", "ResetPassword", new { id = user.Id }, new { @class = "btn btn-warning" })
	</tbody>
</table>
		<!-- Main content -->
		</section>

 然后测试结果出来,OK了。

在这中间,要注样意,你写的视图的代码要改一下,按LIst中间这样,把他加进入。

 <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        Page Header
        <small>Optional description</small>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
        <li class="active">Here</li>
    </section>
    <!-- Main content -->
    <section class="content">
      <!-- Your Page Content Here -->
    </section>
    <!-- /.content -->