css导航栏

CSS | 导航栏 (CSS | Navigation Bar)

Developing websites is great but developing a user-friendly website is even greater. So how does one design a user-friendly website? What tools to use? Well, there are many tools to mention which are quite helpful in making a website user-friendly. So let's discuss one such tool which is Navigation Bar.

开发网站很棒,但是开发用户友好的网站则更大。 那么,如何设计一个用户友好的网站呢? 使用什么工具? 好了,有很多工具值得一提,它们对使网站易于使用非常有帮助。 因此,让我们讨论一种这样的工具,即Navigation Bar

Navigation Bar, what is the first thought that comes into mind after listening to this term. Quite simply though, a menu option for navigating throughout that particular page or site. The navigation bar also lets people move from one page to another. The navigation bar works as a guide for the user to surf through the pages.

导航栏 ,听完该术语后想到的第一个想法是什么。 虽然很简单,但是菜单选项用于浏览特定页面或站点。 导航栏还允许人们从一页移动到另一页。 导航栏可作为用户浏览页面的指南。

The navigation bar is created with the help of menu items taken together. Like an ordered list or unordered list, these list items can be arranged into various positions like horizontally, vertically, right-aligned, etc. Therefore one should be clear in mind about the type of navigation bar he/she wants to use on the webpage.

导航栏是在菜单项结合在一起的情况下创建的。 就像有序列表或无序列表一样,这些列表项可以按水平,垂直,右对齐等各种位置排列。因此,应该牢记他/她想在网页上使用的导航栏的类型。

Besides being aware of the navigation bar, one should also make sure that the links provided in the navigation bar are correct otherwise the user may access the wrong page without even being aware and that creates problems.

除了知道导航栏外 ,还应确保导航栏中提供的链接正确无误,否则用户可能会访问错误的页面而根本不知道并造成问题。

let's talk about some type of navigation bars in detail,

让我们详细讨论一些类型的导航栏,

  1. Vertical navigation bar

    垂直导航栏

  2. Horizontal navigation bar

    水平导航栏

  3. Fixed navigation bar

    固定的导航栏

1)垂直导航栏 (1) Vertical Navigation Bar)

The vertical navigation bar is used to display the menu options vertically. You can use the display property and set it to block. By using display property and setting it to block means that the entire block consisting of your menu item will become clickable. You can also set the width of these blocks as well.

垂直导航栏用于垂直显示菜单选项。 您可以使用display属性并将其设置为block。 通过使用display属性并将其设置为block意味着包含菜单项的整个块将变为可单击。 您也可以设置这些块的宽度。

CSS Syntax:

CSS语法:

    Element
{
display: block;
width: 50px;
}

Example:

例:

<!DOCTYPE html>
<html>
<head>
<style>
li a {display: block;
width: 90px;
background-color: #dddddd;
}
</style>
</head>
<body>
<ul>
<li><a href="#student">student</a></li>
<li><a href="#staff">staff</a></li>
<li><a href="#dean">dean</a></li>
</ul>
</body>
</html>

Output

输出量

In the above example, displaying the links as block elements makes the whole link area clickable.

在上面的示例中,将链接显示为块元素使整个链接区域可单击。

2)水平导航栏 (2) Horizontal Navigation Bar)

In a horizontal navigation bar as the name suggests the elements can be arranged horizontally. Now, this can be done in two ways, first, using inline property and second is by using the floating property.

顾名思义,在水平导航栏中可以将元素水平放置。 现在,这可以通过两种方式完成,一种是使用内联属性,第二种是使用float属性。

1) inline

1)内联

In "inline property" the elements are by default block items, the line break is removed from before and after of each list item so that they can be shown in one line.

默认情况下,在“内联属性”中 ,元素是块项,从每个列表项的前后删除换行符,以便可以将它们显示在一行中。

Syntax for inline:

内联的语法:

    Element{
display: inline;
}

Example:

例:

<!DOCTYPE html>
<html>
<head>
<style>
li {display: inline;
}
</style>
</head>
<body>
<ul>
<li><a href="#student">student</a></li>
<li><a href="#staff">staff</a></li>
<li><a href="#dean">dean</a></li>
</ul>
</body>
</html>

Output

输出量

In the above example, the elements are displayed in a single line.

在上面的示例中,元素显示在一行中。

2) floating:

2)浮动:

"floating property" is used to adjust elements next to each other.

“浮动属性”用于调整彼此相邻的元素。

Syntax for floating:

浮动语法:

    element{
float: left;
}

Example:

例:

<!DOCTYPE html>
<html>
<head>
<style>
li {display: block;
float: left;
}
</style>
</head>
<body>
<ul>
<li><a href="#student">student</a></li>
<li><a href="#staff">staff</a></li>
<li><a href="#dean">dean</a></li>
</ul>
</body>
</html>

Output

输出量

In the above example, the elements are displayed next to each other without any space.

在上面的示例中,元素彼此相邻显示,没有任何空格。

3)固定位置导航栏 (3) Fixed position navigation bar)

These types of navigation bar stay fixed to their positions be it top or bottom even when the user scrolls down or up the page.

即使用户向下或向上滚动页面,这些类型的导航栏也将固定在顶部或底部。

CSS Syntax:

CSS语法:

    Element{
// for fixed top
position: fixed;
// To fix the bar at the top
top: 0;
// for fixed bottom
// To fix the bar at the bottom
bottom: 0;
}

Example:

例:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.topnav {overflow: hidden;
background-color: #333;
}
.topnav a {float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {background-color: #ddd;
color: black;
}
</style>
</head>
<body>
<div class="topnav">
<a class="active" href="#student">student</a>
<a href="#staff">staff</a>
<a href="#dean">dean</a>
</div>
<div style="padding-left:16px">
<p>Some content..</p>
</div>
</body>
</html>

Output

输出量

In the above example, the navigation stays at top even when we scroll the page.

在上面的示例中,即使我们滚动页面,导航也位于顶部。

翻译自: https://www.includehelp.com/code-snippets/navigation-bar-using-css.aspx

css导航栏

css导航栏_使用CSS的导航栏相关推荐

  1. css 菜单栏悬停_在CSS中构建悬停菜单

    css 菜单栏悬停 A good menu design is an important part of any website or web app UI. Using only modern HT ...

  2. css覆盖规则_条件 CSS

    在CSS的世界中,总是有很多实验性的属性先行,正因为这些先行者在不断的探索新的特性,才让CSS越来越强大.而这些实验性的特性并没有立马得到众多浏览器的支持,为了能让这些实验性特性能在部分支持的浏览器上 ...

  3. css 绘制三角形_解释CSS形状:如何使用纯CSS绘制圆,三角形等

    css 绘制三角形 Before we start. If you want more free content but in video format. Don't miss out on my Y ...

  4. css flexbox模型_完整CSS课程-包括flexbox和CSS网格

    css flexbox模型 Learn CSS in this complete 83-part course for beginners. Cascading Style Sheets (CSS) ...

  5. WordPress仿114网站导航仿爱导航网站_简约大气网站导航源码网址导航模板源码下载

    114导航是一款原创设计开发的WordPress网址导航主题,适用于创建漂亮.强大的导航类网站.这款导航主题的首页采用模块化设计,可以添加不同链接分类下的链接,每个模块都可以选择是否显示链接图标.链接 ...

  6. Java制作二级导航菜单_纯CSS实现超简单的二级下拉导航菜单代码

    本文实例讲述了纯CSS实现超简单的二级下拉导航菜单代码.分享给大家供大家参考.具体如下: 这是一款纯CSS菜单,二级下拉导航效果,是最简洁的CSS导航菜单,兼容性也很棒,IE7/8.火狐等都支持,而且 ...

  7. css 倒三角_改善CSS的10种最佳做法

    CSS似乎是一种非常简单的语言,很难在其中犯错误.你只需添加样式规则,就可以对网站进行样式设置了,对吗?对于只需要几个CSS文件的小型网站,情况可能就是这样.但是在大型应用程序中,样式可能会迅速失控. ...

  8. css 倒三角_改善CSS的10种最佳做法,帮助你从样式中获得最大的收益。

    翻译:英文 | https://medium.com/better-programming/10-best-practices-for-improving-your-css-84c69aac66e C ...

  9. css 汉堡菜单_使用CSS构建变形汉堡包菜单

    css 汉堡菜单 Rencently I've found this awesome dribbble shot by Vitaly Rubtsov, and I could not resist t ...

最新文章

  1. 矩阵拼接 cat padding_pytorch
  2. 极客邦科技旗下TGO鲲鹏会成立美国硅谷分会
  3. 20100422.C#.const VS readonly
  4. js时间戳格式化成日期格式
  5. iOS开发日记4-第三方登录(ShareSDK)
  6. 牛客 - 牛牛的Link Power II(线段树)
  7. 华为云服务器密码修改,华为云鲲鹏云服务器安装MySQL 5.7.30
  8. Chromium Microsoft Edge 浏览器现已可供下载
  9. Zabbix(二)通过API在zabbix系统中查看、删除及创建监控主机
  10. VMware下ubuntu全屏显示
  11. Linux文本加密方法,Linux命令行文本加密的小技巧
  12. unity天空盒渐变_Unity 制作天空盒
  13. 简单聊聊网页的资源加载优化
  14. 数独解题程序的python实现_使用Python编写程序求解数独游戏答案
  15. 【数理知识】Lipschitz 条件 Lipschitz 常数
  16. 一点还算不郁闷的郁闷的事
  17. ionic3 生命周期方法
  18. 微信公众平台可以修改微信号了,微信号怎么设置好。
  19. 符合lft, rgt的无限分类算法的Java生成代码
  20. 应届毕业第三年就升职360技术总监,总结3点晋升心得

热门文章

  1. 倒序查10条数据_10 | 怎么给字符串字段加索引?
  2. Docker容器的重启策略
  3. 超详细MFS网络分布式文件系统
  4. 序(不知道是什么时候的模拟题)
  5. ISA Server 2006 部署步骤
  6. Ubuntu抛弃了Untiy转向Gnome,美化之路怎么办?不用怕咱一步一步大变身!
  7. LCD显示屏原理与应用
  8. 在HubSpot是如何应对Fat JAR困境的
  9. Android 基本测试工具的使用
  10. linux下得到date命令,linux下date命令获得今天日期的用法