bootstrapadminlte教程1:基础布局⼀、下载adminlte
官⽹:almsaeedstudio/
github:github/almasaeed2010/AdminLTE/
⼆、引⽤的基本解说
1、meta没的说
2、引⼊bootstrap
3、引⼊字体库,肯定⽤得到,下载到本地放在plugins下也可以
4、adminLTE⼦什么的⽂件肯定需要
5、⽪肤skin,可以引⼊_,但是如果只需要⼀个⽪肤的话,⽐如只需要蓝⾊,直接引⼊skin-blue就⾏,毕竟越简越好
6、兼容IE8的两个js⽂件
7、jquery没的说
8、fastclick,触摸设备快速点击体验,不想兼容⼿机可以去掉
9、slimscroll,菜单和页⾯中的滚动条样式,放上去毕竟好看嘛。(看⼀下不加的效果,不好看吧)
下⾯是引⽤的原代码,可是⽤starter.htm中查看,对应上⾯的进⾏查看
<head>
<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="cdnjs.cloudflare/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="cdnjs.cloudflare/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="oss.maxcdn/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="oss.maxcdn/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-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">
</div>
<!-- 底部标注 -->
<footer class="main-footer">
</footer>
<!-- 右侧菜单栏 -->
<aside class="control-sidebar control-sidebar-dark">
</aside>
<!-- 右侧菜单栏的样式,底部距离为0等 -->
<div class="control-sidebar-bg"></div>
</div>
四。在MVC5项⽬中加⼊adminlte
1.我将adminlte全部复制进 Content⽂件夹下
2.在MVC5项⽬中将adminlte⽂件夹及⽂件包含进项⽬。
六.bundles相关的JS和CSS
1.我将引⽤⼆个远程CSS下载下来到本地的CSS夹中,我是放在bootstrap/css/下⾯的,结果这个⽅法是错误的,他的远程的⼆个主要是字体图标的引⽤,必须远程,否得你得更改内容或是下下来。 <!-- Font Awesome -->
<link rel="stylesheet" href="cdnjs.cloudflare/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
js导航栏下拉菜单<link rel="stylesheet" href="cdnjs.cloudflare/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/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>
<html>
<head>
<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="cdnjs.cloudflare/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"> <!-- Ionicons -->
<link rel="stylesheet" href="cdnjs.cloudflare/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="oss.maxcdn/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="oss.maxcdn/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>
</a>
<!-- 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>
</a>
<!-- 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>
</a>
<ul class="dropdown-menu">
<li class="header">You have 4 messages</li>
<li>
<!-- inner menu: contains the messages -->
<ul class="menu">
<li>
<!-- start message -->
<a href="#">
<div class="pull-left">
<!-- User Image -->
<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
</div>
<!-- Message title and timestamp -->
<h4>
Support Team
<small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<!-- The message -->
<p>Why not buy a new awesome theme?</p>
</li>
<!-- end message -->
</ul>
<!-- /.menu -->
</li>
<li class="footer"><a href="#">See All Messages</a></li>
</ul>
</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>
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- Inner Menu: contains the notifications 喇叭图标那个-->
<ul class="menu">
<li>
<!-- start notification -->
<a href="#">
<i class="fa fa-users text-aqua"></i> 5 new members joined today
</a>
</li>
<!-- end notification -->
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</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>
</a>
<ul class="dropdown-menu">
<li class="header">You have 9 tasks</li>
<li>
<!-- Inner menu: contains the tasks -->
<ul class="menu">
<li>
<!-- Task item -->
<a href="#">
<!-- Task title and progress text -->
<h3>
Design some buttons
<small class="pull-right">20%</small>
</h3>
<!-- The progress bar -->
<div class="progress xs">
<!-- Change the css width attribute to simulate progress -->
<div class="progress-bar progress-bar-aqua" role="progressbar" aria-valuenow="
20" aria-valuemin="0" aria-valuemax="100"> <span class="sr-only">20% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
</ul>
</li>
<li class="footer">
<a href="#">View all tasks</a>
</li>
</ul>
</li>
<!-- 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>
</a>
<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">
<p>
Alexander Pierce - Web Developer
<small>Member since Nov. 2012</small>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论