今天学习了Bootstrap框架,对其进行引入与基本布局
引用:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <!--导入bootstrap样式文本css--> <link rel="stylesheet" href="css/bootstrap.css"> <title>Document</title> </head> <body> <img src="images/1.jpg" alt="" class="img-responsive img-circle"> <div class="alert alert-danger"> <a href="" class="close" data-dismiss="alert">X</a> <strong>警告:</strong>您已非法操作 </div> <!--导入支持文件:jquery--> <script src="js/jquery-3.3.1.min.js"></script> <!--导入bootstrap的js文件--> <script src="js/bootstrap.js"></script> </body> </html>
点击 "运行实例" 按钮查看在线实例
浏览图:
基本博客布局
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="css/bootstrap.css"> <title>博客布局</title> <style> .grid { border: 1px solid #696969; border-radius: 5px; background-color: lightskyblue; min-height: 50px; text-align: center; line-height: 50px; } </style> </head> <body> <div class="container"> <div class="row"> <div class="col-md-12"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">博客</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">首页 <span class="sr-only">(current)</span></a></li> <li><a href="#">发布</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">应用 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">直播</a></li> <li><a href="#">新闻</a></li> <li role="separator" class="divider"></li> <li><a href="#"></a>其他应用</li> </ul> </li> </ul> <form class="navbar-form navbar-left"> <div class="form-group"> <input type="text" class="form-control" placeholder="搜索内容"> </div> <button type="submit" class="btn btn-default">搜索</button> </form> <ul class="nav navbar-nav navbar-right"> <li><a href="#">登陆</a></li> <li><a href="#">注册</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">邮箱 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">免费注册</a></li> <li><a href="#">VIP邮箱</a></li> <li><a href="#">企业邮箱</a></li> <li role="separator" class="divider"></li> <li><a href="#">***端下载</a></li> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="row"> <div class="col-md-6"> <div class="page-header"> <h1>最新新闻 <small>关注生活每一天</small> </h1> </div> <div class="list-group"> <a href="#" class="list-group-item active"> PHP中文网是中国最大的PHP网站 </a> <a href="#" class="list-group-item">PHP语言是最好的语言</a> <a href="#" class="list-group-item">我爱PHP</a> </div> </div> <div class="col-md-6"> <img src="images/1.jpg" alt="" class="img-responsive img-circle"> </div> </div> </div> <script src="js/jquery-3.3.1.min.js"></script> <script src="js/bootstrap.js"></script> </body> </html>
点击 "运行实例" 按钮查看在线实例
浏览图
总结:
使用Bootstrap框架,能够更加效率的实现响应式布局,它拥有完备的框架结构,整体效果和谐,对谷歌,火狐,IE等浏览器均可支持,项目开发方便快捷,扩展性强,能够更好的与现实的web开发项目结合,拥有完善的文档,使用起来更方便。