Bootstrap 常用框架的使用
自定义模态对话框:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#staticBackdrop">弹框</button>
<div class="modal fade" id="staticBackdrop" data-backdrop="static" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">编辑模式</h5>
</div>
<div class="modal-body">
<!--主体部分-->
<div class="form-group row">
<label class="col-sm-2 col-form-label">用户名:</label>
<div class="col-sm-10">
<input type="text" class="form-control">
</div>
</div>
</div>
<!--尾部内容-->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary">提交数据</button>
</div>
</div>
</div>
Bootstrap-table 表格的使用技巧
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hello, Bootstrap Table!</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.js"></script>
</head>
<script type="text/javascript">
//模拟数据
var tableData = [
{id:1001,name:"小红",age:"15",sex:"男"},
{id:1002,name:"admin",age:"13",sex:"女"}
]
$(document).ready(function () {
$(\'#table\').bootstrapTable({
data: tableData,
uniqueId: "id",
locale: "zh-CN", // 语言
toolbar: "#toolbar", // 工具栏
search: true, // 显示搜索
height: document.documentElement.clientHeight,//根据页面高度定义表格高度
showColumns: true, //隐藏列
striped: true, // 是否显示行间隔色
showRefresh: true, // 是否显示刷新按钮
clickToSelect: true, // 是否启用点击选中行
showToggle: true, // 是否显示详细视图和列表视图的切换按钮
cardView: false, // 是否显示详细视图javascript:void(0)
sortable: true, // 是否启用排序
sortOrder: "asc", // 排序方式
pagination: true, // 是否显示分页
sidePagination: "client", // 分页方式:client客户端分页,server服务端分页
columns: [
{ field: \'name\', title: \'名称\', sortable: true, width: 280 },
{ field: \'age\', title: \'年龄\', sortable: true, width: 280 },
{ field: \'sex\', title: \'性别\', sortable: true, width: 280 },
]
});
});
</script>
</head>
<body>
<div id="toolbar"></div><!--工具栏-->
<table id="table"></table><!--表格-->
</body>
</html>
左侧导航栏
<!DOCTYPE html>
<html lang="zh"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" >
<link href="https://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css" rel="stylesheet" media="screen">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="./sidebar-menu.css">
<script src="./sidebar-menu.js"></script>
<style type="text/css">
.main-sidebar{
position: absolute;
top: 0;
left: 0;
height: 100%;
min-height: 100%;
width: 230px;
z-index: 810;
background-color: #222d32;
}
</style>
</head>
<body>
<aside class="main-sidebar">
<section class="sidebar">
<ul class="sidebar-menu">
<li class="header">主导航</li>
<li class="treeview active">
<a href="#">
<i class="fa fa-dashboard"></i> <span>仪表盘</span> <i class="fa fa-angle-right pull-right"></i>
</a>
<ul class="treeview-menu" style="display: block;">
<li><a href="#"><i class="fa fa-circle-o"></i> CPU负载</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> 内存负载</a></li>
</ul>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-files-o"></i>
<span>布局选项</span>
<span class="label label-primary pull-right">4</span>
</a>
<ul class="treeview-menu" style="display: none;">
<li><a href="#"><i class="fa fa-circle-o"></i> 顶部导航</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> 盒子布局</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> 固定布局</a></li>
<li class=""><a href="#"><i class="fa fa-circle-o"></i> 折叠侧边栏</a>
</li>
</ul>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-pie-chart"></i>
<span>权限管理</span>
<i class="fa fa-angle-right pull-right"></i>
</a>
<ul class="treeview-menu menu-open" style="display: none;">
<li><a href="#"><i class="fa fa-circle-o"></i> ChartJS</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> Morris</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> Flot</a></li>
<li><a href="#"><i class="fa fa-circle-o"></i> Inline charts</a></li>
</ul>
</li>
</section>
</aside>
<script>
$.sidebarMenu($(\'.sidebar-menu\'))
</script>
</body>
</html>
sidebar-menu.css
.sidebar-menu{list-style:none;margin:0;padding:0;background-color:#222d32}.sidebar-menu>li{position:relative;margin:0;padding:0}.sidebar-menu>li>a{padding:12px 5px 12px 15px;display:block;border-left:3px solid transparent;color:#b8c7ce}.sidebar-menu>li>a>.fa{width:20px}.sidebar-menu>li:hover>a,.sidebar-menu>li.active>a{color:#fff;background:#1e282c;border-left-color:#3c8dbc}.sidebar-menu>li>.treeview-menu{margin:0 1px;background:#2c3b41}.sidebar-menu>li .label,.sidebar-menu>li .badge{margin-top:3px;margin-right:5px}.sidebar-menu li.header{padding:10px 25px 10px 15px;font-size:12px;color:#4b646f;background:#1a2226}.sidebar-menu li>a>.fa-angle-left{width:auto;height:auto;padding:0;margin-right:10px;margin-top:3px}.sidebar-menu li.active>a>.fa-angle-left{transform:rotate(-90deg)}.sidebar-menu li.active>.treeview-menu{display:block}.sidebar-menu a{color:#b8c7ce;text-decoration:none}.sidebar-menu .treeview-menu{display:none;list-style:none;padding:0;margin:0;padding-left:5px}.sidebar-menu .treeview-menu .treeview-menu{padding-left:20px}.sidebar-menu .treeview-menu>li{margin:0}.sidebar-menu .treeview-menu>li>a{padding:5px 5px 5px 15px;display:block;font-size:14px;color:#8aa4af}.sidebar-menu .treeview-menu>li>a>.fa{width:20px}.sidebar-menu .treeview-menu>li>a>.fa-angle-left,.sidebar-menu .treeview-menu>li>a>.fa-angle-down{width:auto}.sidebar-menu .treeview-menu>li.active>a,.sidebar-menu .treeview-menu>li>a:hover{color:#fff}
sidebar-menu.js
$.sidebarMenu=function(menu){var animationSpeed=300;$(menu).on(\'click\',\'li a\',function(e){var $this=$(this);var checkElement=$this.next();if(checkElement.is(\'.treeview-menu\')&&checkElement.is(\':visible\')){checkElement.slideUp(animationSpeed,function(){checkElement.removeClass(\'menu-open\');});checkElement.parent("li").removeClass("active");}
else if((checkElement.is(\'.treeview-menu\'))&&(!checkElement.is(\':visible\'))){var parent=$this.parents(\'ul\').first();var ul=parent.find(\'ul:visible\').slideUp(animationSpeed);ul.removeClass(\'menu-open\');var parent_li=$this.parent("li");checkElement.slideDown(animationSpeed,function(){checkElement.addClass(\'menu-open\');parent.find(\'li.active\').removeClass(\'active\');parent_li.addClass(\'active\');});}
if(checkElement.is(\'.treeview-menu\')){e.preventDefault();}});}
导航栏下拉菜单
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>导航栏下拉菜单</title>
<style>
*{margin:0;padding:0;}
ul{
list-style-type:none;
background-color:#333;
overflow:hidden;
}
li{
float:left;
}
li a, .dropbtn{
display:inline-block;
color:white;
text-align:center;
padding:14px 16px;
text-decoration:none;
}
li a:hover, .dropdown:hover .dropbtn{
background-color:#111;
}
.dropdown{
display:inline-block;
}
.dropdown-content{
min-width:200px;
background-color:#F9F9F9;
position:absolute;
display:none;
box-shadow:0px 8px 15px 0px rgba(0,0,0,0.2);
}
.dropdown-content a{
color:black;
padding:12px 16px;
text-decoration:none;
display:block;
}
.dropdown-content a:hover{
background-color:#F1F1F1;
}
.dropdown:hover .dropdown-content{
display: block;
}
</style>
</head>
<body>
<ul>
<li><a href="#shop" class="active">产品主页</a></li>
<li><a href="#news">产品展示</a></li>
<div class="dropdown">
<a href="#" class="dropbtn">下拉菜单</a>
<div class="dropdown-content">
<a href="#">子菜单 1</a>
<a href="#">子菜单 2</a>
<a href="#">子菜单 3</a>
</div>
</div>
</ul>
</body>
</html>
二级下拉菜单代码
heang.css
body{
margin: 0;
padding: 0;
background-color: #F3F3F3;
font-size: 14px;
font-family: \'Microsoft YaHei\', \'Times New Roman\', Times, serif;
letter-spacing: 0;
min-width: 1200px;
color: #333333;
}
.hl_nav{
background-color: #FD463E;
position: relative;
color: #ffffff;
min-width: 1200px;
height: 64px;
}
.hl_nav a{
display: block;
text-decoration: none;
}
.hl_nav .shade{
position: absolute;
width: 100%;
height: 200px;
top: 64px;
left: 0;
z-index: 1;
background-color: #EEEEEE;
opacity: 0.9;
filter: alpha(opacity=90);
box-shadow: 0 5px 15px #CCCCCC;
display: none;
border-bottom: #ffffff solid 1px;
border-bottom: rgba(255,255,255,0.3) solid 1px;
}
.hl_nav .nav_list{
position: absolute;
top: 0;
left: 50%;
margin: 0 0 0 -600px;
z-index: 2;
padding: 0;
list-style: none;
width: 1200px;
overflow: hidden;
height: 64px;
}
.hl_nav .nav_list>li{
padding: 0;
float: left;
margin: 0;
width: 120px;
text-align: center;
height: 264px;
}
.hl_nav .nav_head{
height: 64px;
line-height: 64px;
color: #ffffff;
font-size: 16px;
background-color: #FD463E;
}
.hl_nav .nav_head .icon{
font-size: 18px;
}
.hl_nav .item{
height: 40px;
line-height: 40px;
color: #333333;
position: relative;
}
.hl_nav .item:hover:after{
content: \'\';
display: block;
position: absolute;
width: 60px;
height: 2px;
bottom: 5px;
left: 30px;
background-color: #FD463E;
}
.hl_nav .nav_list:hover{
height: 264px;
transition: height 0.3s;
}
.hl_nav .nav_list:hover + .shade{
display: block;
}
.hl_nav .nav_list>li.highlight:hover{
background-color: #ffffff;
}
.hl_nav .nav_list>li:hover .nav_head,.hl_nav .nav_list>li.active .nav_head{
background-color: #EA0D04;
}
.hl_nav .nav_list>li.right{
float: right;
}
.hl_nav .nav_list>li:hover .item{
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>超实用的CSS3横向</title>
<link rel="stylesheet" href="./helang.css">
<!--图标样式-->
<link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
<style type="text/css">
.info_box{
margin: 100px auto 0 auto;
width: 400px;
background-color: #ffffff;
color: #333333;
padding:0 0 0 30px;
}
.info_box>li{
padding: 15px 0;
font-size: 14px;
border-top: #e5e5e5 dashed 1px;
}
.info_box>li:first-child{
list-style: none;
font-size: 16px;
color: #FD463E;
border-top: none;
font-weight: bold;
}
.info_box>li:last-child{
list-style: none;
font-size: 12px;
color: #999999;
}
</style>
</head>
<body>
<div style="text-align:center;clear:both;">
<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>
<nav class="hl_nav">
<ul class="nav_list">
<li class="highlight active">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-home"></i>
<span>网站首页</span>
</a>
<a href="javascipt:;" class="item">二级导航1</a>
<a href="javascipt:;" class="item">二级导航2</a>
<a href="javascipt:;" class="item">二级导航3</a>
<a href="javascipt:;" class="item">二级导航4</a>
<a href="javascipt:;" class="item">二级导航4</a>
</li>
<li class="highlight">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-cloud-download"></i>
<span>在线下载</span>
</a>
<a href="javascipt:;" class="item">二级导航1</a>
<a href="javascipt:;" class="item">二级导航2</a>
<a href="javascipt:;" class="item">二级导航3</a>
</li>
<li class="highlight">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-diamond"></i>
<span>成功案例</span>
</a>
<a href="javascipt:;" class="item">二级导航1</a>
<a href="javascipt:;" class="item">二级导航2</a>
<a href="javascipt:;" class="item">二级导航3</a>
<a href="javascipt:;" class="item">二级导航4</a>
<a href="javascipt:;" class="item">二级导航4</a>
</li>
<li class="highlight">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-list-alt"></i>
<span>新闻动态</span>
</a>
<a href="javascipt:;" class="item">二级导航1</a>
<a href="javascipt:;" class="item">二级导航2</a>
<a href="javascipt:;" class="item">二级导航3</a>
</li>
<li class="highlight">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-comments"></i>
<span>与我联系</span>
</a>
<a href="javascipt:;" class="item">二级导航1</a>
<a href="javascipt:;" class="item">二级导航2</a>
</li>
<li>
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-user"></i>
<span>关于我们</span>
</a>
</li>
<li class="right highlight">
<a class="nav_head" href="javascipt:;">
<i class="icon fa fa-cog "></i>
<span>个人中心</span>
</a>
<a href="javascipt:;" class="item">修改资料</a>
<a href="javascipt:;" class="item">在线充值</a>
<a href="javascipt:;" class="item">升级会员</a>
<a href="javascipt:;" class="item">安全设置</a>
<a href="javascipt:;" class="item">退出帐号</a>
</li>
</ul>
<div class="shade"></div>
</nav>
</body>
</html>