分享好友 前端技术首页 频道列表

bootstrap之navbar

bootstrap  2023-03-08 18:470

 

 

container:固定960px宽度,(如果又引入了响应式样式,则会适当调整,例如1600*900,它会显示1200px) 

container-fluid:自适应屏幕宽度,即满屏显示。

 row和col可以参考一下:https://blog.csdn.net/yzy85/article/details/53021385?locationNum=2&fps=1和http://v3.bootcss.com/css/

尤其http://v3.bootcss.com/css/讲的特别清楚哦

例如:

使用单一的一组 .col-md-* 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” .row 内。

bootstrap之navbar

 

 

 

.navbar——设置nav元素为导航条组件;

.navbar-default——指定导航条组件为默认主题;

.navbar-inverse——指定导航条组件为黑色主题;

.navbar-fixed-top——设置导航条组件固定在顶部;

.navbar-fixed-bottom——设置导航条组件固定在底部;

.container-fluid——设置宽度充满父元素,即为100%;

.navbar-header——主要指定div元素为导航条组件包裹品牌图标及切换按钮;

.navbar-toggle——设置button元素为导航条组件的切换钮;

.collapsed——设置button元素为在视口小于768px时才显示;

.navbar-brand——设置导航条组件内的品牌图标;

navbar-brand默认是放文字的,也可以放图片,但必须是小图片,如果图片太大,位置就会靠下.

例子:

<head>
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.css') }}">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!--小屏幕导航按钮和logo-->
<div class="navbar-header">
<a href="" class="navbar-brand" style="width:250px;">
<img src="{{ url_for('static', filename='base/images/logo.png') }}" style="height:30px;">&nbsp;STEM教育
</a>
</div>
</div>
</nav>
</body>
代码执行时,样式是这样的:

bootstrap之navbar

我们发现图标和字体是错位了。我们只需要在加入:display: inline;就可以了,加入后的代码如下:

<head>
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.css') }}">
</head>
<body>

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
<!--小屏幕导航按钮和logo-->
<div class="navbar-header">
<a href="" class="navbar-brand" style="width:250px;">
<img src="{{ url_for('static', filename='base/images/logo.png') }}" style="height:30px;display:inline;">&nbsp;STEM教育
</a>
</div>
</div>
</nav>
</body>
代码执行后,样式如下图,已经成为我们想要的样子了:

bootstrap之navbar

也可以这样写:

<head>
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.css') }}">
<style>
.navbar-brand>img {
display: inline;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!--小屏幕导航按钮和logo-->
<div class="navbar-header">
<a href="" class="navbar-brand" style="width:250px;">
<img src="{{ url_for('static', filename='base/images/logo.png') }}" style="height:30px;">&nbsp;STEM教育
</a>
</div>
</div>
</nav>
</body>
效果是一样的:

bootstrap之navbar

解释:

display:inline 的作用是设置对象做为行内元素显示,也就是它能够将垂直排列变成横向排列。



 

 

 

.collapse——设置div元素为视口大于768px时显示;

.navbar-collapse——设置div元素为导航条组件各列表项的父元素;

这里说的有点不清楚,我解释一下,collapse的作用是为了当浏览器的窗口宽度小于768px的时候,将设置为collapse样式的div元素内的所有其它元素都折叠起来,以一个列表的形式显示。

例子:

bootstrap之navbar

 

 可以看到以现在的大小,还没有进行折叠,当再缩小时,就会折叠:

bootstrap之navbar

 

 

.navbar-nav——设置ul为导航条组件内的列表元素;

.navbar-left——设置导航条内元素向左对齐;

.navbar-right——设置导航条内元素向右对齐;

当出现navbar-right时:

<div class="navbar-collapse collapse">
<form class="navbar-form">
<div class="form-group input-group">
<input type="text" class="form-control" ></span>&nbsp;退出</a>
</li>
</ul>
</div>
运行结果如下:

bootstrap之navbar

可以看出form和ul不在同一行,这是因为ul使用navbar-right指定靠右显示,而form并未指定靠左还是靠右。应该将form指定靠左显示,即设置样式为navbar-left

<div class="navbar-collapse collapse">
<form class="navbar-form navbar-left">
<div class="form-group input-group">
<input type="text" class="form-control" ></span>&nbsp;退出</a>
</li>
</ul>
</div>
执行解决为:

bootstrap之navbar

 在ul标签中使用了navbar-nav的样式,如果没有使用的话:

<ul class="nav  navbar-right">
<li>
<a ><span class="glyphicon glyphicon-log-in"></span>&nbsp;登录</a>
</li>
<li>
<a ><span class="glyphicon glyphicon-log-out"></span>&nbsp;退出</a>
</li>
</ul>

bootstrap之navbar

会导致两个li标签在不同的行,加上navbar-nav后,可以使两个li标签在同一行显示。

 




 

.navbar-form——为导航条组件内部的表单组件;

navbar-form:主要调整所有form都为行内元素

 

.navbar-btn——为导航条组件内部的按钮样式;

.navbar-text——为导航条组件内部的文本样式;

.navbar-link——在标准的导航组件之外添加标准链接,让链接有正确的颜色和反色设置;

.breadcrumb——设置列表元素显示为路径导航组件;

 

 

form-goup和input-goup参考:https://blog.csdn.net/qq_15267341/article/details/54016811写的很好哦。

<span class="glyphicon glyphicon-search"></span>通常用户放在搜索字体的前面,显示一个小小的搜索图标,如下图:

bootstrap之navbar

.btn 是按钮的基础,主要是调整盒模型的,.btn-default 以及其他 .btn-* 系列则是视觉样式的调整,如颜色、大小等等。

例子:

<a ><span class="glyphicon glyphicon-search"></span>搜索</a>
运行效果是:

bootstrap之navbar

非常难看,鼠标放上去的时候,字体下面还会出现一根横线。如果将a元素的样式设置成btn btn-default时,就好看多了,代码如下:

bootstrap之navbar

鼠标放上去的时候,也没有横线的,只是由白色编程灰色了:

bootstrap之navbar

 

 

input-group-btn的作用:
例子:
<form class="navbar-form">
<div class="form-group input-group">
<input type="text" class="form-control" ></span>搜索</a></span>
</div>
</form>
运行效果如下:

bootstrap之navbar

想要将搜索放在文本框后面,只需要将入input-group-btn样式就可以了:

 

<div class="navbar-collapse collapse">
<form class="navbar-form">
<div class="form-group input-group">
<input type="text" class="form-control" ></span>搜索</a></span>
</div>
</form>
</div>运行结果如下:

 

bootstrap之navbar

 

 

如果将input-group-btn换成input-group-addon后,就会变成如下的样子:

bootstrap之navbar

 

是不是很难看?

 

 

 

 

 



 



 

查看更多关于【bootstrap】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
Bootstrap基础:选择器
1.CSS属性选择器[arrt=value]   该属性有指定的确切值[arrt~=value]  该属性值必须是多个空格隔开的值,比如,class=“title featured home”,而且这些值中的一个必须是指定的值“value”[arrt|=value]  属性的值就是“value”或者以“value”开始并立即

0评论2023-03-16469

Bootstrap.css 中请求googleapis.com/css?family 备忘录
问题描述: Web中引入bootstrap.css中头部有访问Google服务器的请求 @import url("//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700");     国内访问不稳定,页面反应慢解决:将请求结果保存下来,放到本地,重新声明请求1.请求http:

0评论2023-03-16312

基于.NET6、FreeSql、若依UI、LayUI、Bootstrap构建插件式的CMS
近几年,.net生态日益强大,特别是跨平台技术,性能提升,那真的是强大无比。为了日常能够快速开发,笔者基于基于.NET6、FreeSql、若依UI、LayUI、Bootstrap构建插件式的CMS,请大家多提意见建议。在此,要感谢若依CMS的作者,借用了皮肤框架。懒的发文字描述

0评论2023-03-16505

elasticsearch bootstrap.memory_lock
检查bootstrap.memory_lock设置是否生效get http://10.127.0.1:9200/_nodes?filter_path=**.mlockall响应:{"nodes": {"9giihmDNRdS136KT52Gl5g": {"process": {"mlockall": true}},"X0zQESeeT8uJ9kVXvHpl-w": {"process":

0评论2023-03-08659

50 个 Bootstrap 插件
Bootstrap是快速开发Web应用程序的前端工具包。它是一个CSS和HTML的集合,它使用了最新的浏览器技术,给你的Web开发提供了时尚的版式,表单,buttons,表格,网格系统等等。本文向你推荐 50 个 Bootstrap 的插件,可以考虑在你下一个项目中使用它们。1. Boots

0评论2023-03-08629

Bootstrap资源 bootstrap官方文档
官方网站:http://getbootstrap.com/http://twitter.github.com/bootstrap/index.html 官方博客:http://blog.getbootstrap.com/  中文文档:http://wrongwaycn.github.com/bootstrap/docs/index.html  图标:Font Awesomehttp://fortawesome.github.com

0评论2023-03-08321

bootstrap bootstrap检验
bootstrap是简洁灵活的用于搭建web页面的Html,Css工具集。---是一组简洁强大的前端开发框架。 Bootstrap是Twitter推出的一个开源的用于前端开发的工具包。是一个CSS/HTML框架。bootstrap中的js框架依赖于jquery,因此jquery要在bootstrap之前引进一般要把CS

0评论2023-03-08325

002-BootStrap基本模板 bootstrap 模型
!DOCTYPE htmlhtml lang="zh-CN"headmeta charset="utf-8"!--声明文档兼容模式,表示使用IE浏览器的最新模式--meta http-equiv="X-UA-Compatible" content="IE=edge"!--设置视口的宽度(值为设备的理想宽度),页面初始缩放值理想宽度/可见宽度--meta name="vie

0评论2023-03-08506

003-BootStrap完整模板 bootstrap demo
!DOCTYPE htmlhtml lang="zh-CN"headmeta charset="utf-8"!--声明文档兼容模式,表示使用IE浏览器的最新模式--meta http-equiv="X-UA-Compatible" content="IE=edge"!--设置视口的宽度(值为设备的理想宽度),页面初始缩放值理想宽度/可见宽度--!--视口的作用

0评论2023-03-08910

nginx 下 bootstrap fa 字体异常问题
server {listen 8082;#server_name192.168.16.88; #root/home/ywt/workspace/kuF/web/statics;#autoindex on; #autoindex_exact_size off; #autoindex_localtime on; # } 原配置如上,实际图标加载出来乱七八糟; 经过具体分析,实际css文件正常加载,字体

0评论2023-03-08960

bootstrap 响应式布局
先上点媒体查询css(某个著名的”段子“),跟bootstrap无关:htmlheadstylebody {background-color: white;}@media screen and (max-width: 960px){body {background-color: red;}}@media screen and (max-width: 768px){body {background-color: yellow;}}@

0评论2023-03-08482

bootstrap bootstrap用什么软件
bootstrap:简易模版:meta http-equiv='X-UA-Compatible' content='IE=edge' //让IE浏览器运行最新的渲染模式//meta name='renderer' content='webkit'让部分国产浏览器默认采用高速模式渲染页面meta name='viewport' content='width=device-width,initail-

0评论2023-03-08809

bootstrap怎样让按钮或者组件左右对齐 bootstrap怎么调整组件的位置
1.登录页的form表单可以是使用margin:0 auto的方式,居中对齐 2.div可以使用pull-right, text-center, pull-left 3.按钮或者p标签可以使用text-right, text-center, text-left

0评论2023-03-08949

更多推荐