css导航栏_使用CSS的导航栏

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

输出量

Navigation bar using CSS | Example 1

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

输出量

Navigation bar using CSS | Example 2

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

输出量

Navigation bar using CSS | Example 3

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

输出量

Navigation bar using CSS | Example 4

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导航栏

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543898.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java代理系列-静态代理

2019独角兽企业重金招聘Python工程师标准>>> 代理模式可以做很多事&#xff0c;像hibernate&#xff0c;spring都使用了代理模式。 spring的aop就是用代理做的。 本系列分为4章&#xff0c;静态代理&#xff0c;动态代理热身&#xff0c;动态代理&#xff0c;cglib代…

ajax的模式_AJAX的完整形式是什么?

ajax的模式AJAX&#xff1a;异步JavaScript和XML (AJAX: Asynchronous JavaScript and XML) AJAX is an abbreviation of Asynchronous JavaScript and XML. It is an organized collection of technologies and not of a single technology. Informing a collection of web De…

JAVA Opencv在图片上添加中文

问题描述&#xff1a; 将图片进行均值、中值、高斯滤波&#xff0c;高斯边缘检测&#xff0c;并在图片上添加中文文字。 一、算法思想 首先经过opencv的一系列操作&#xff0c;例如高斯模糊、均值模糊等操作后、用Imgcodecs.imwrite方法将图片写出到指定的位置。再利用java…

双向tvs和单向tvs_TVS的完整形式是什么?

双向tvs和单向tvsTVS&#xff1a;Thirukkurungudi Vengaram Sundram (TVS: Thirukkurungudi Vengaram Sundram) TVS is an abbreviation of Thirukkurungudi Vengaram Sundram. It is a multinational motorcycle business corporation, which is one of the largest manufactu…

引用头文件报错 .pch引用不了其他的.h文件

2019独角兽企业重金招聘Python工程师标准>>> 一、编绎显示Unknown type name “CGFloat” 错误解决方法 将Compile Sources As 改为 Objective-C 二、如果是extern const引起的。直接加头文件 #import <UIKit/UIKit.h> 最后在 .h文件 #import <UIKit/UIK…

ibm mq的交互命令模式_IBM的完整形式是什么?

ibm mq的交互命令模式IBM&#xff1a;国际商业机器 (IBM: International Business Machines) IBM is an abbreviation of International Business Machines. It is an I.T based multinational and consulting corporation which is also an American trusted brand in the IT …

r软件说明lib文件未指明_软件说明文件

r软件说明lib文件未指明The software primarily consists of Computer Programs and the associated documentation. We all know that the computer program is the baseline of the entire software, but the documentation part is also as important as the programming pa…

dfa与ndfa_DFA和NDFA之间的区别| 目录

dfa与ndfaDFA stands for Deterministic Finite Automata and NDFA stands for Non-Deterministic Finite Automata. DFA代表确定性有限自动机&#xff0c;而NDFA代表非确定性有限自动机。 Read more: Deterministic Finite Automata (DFA) 阅读更多&#xff1a; 确定性有限自…

css圆角三角形3个圆角_CSS中的圆角

css圆角三角形3个圆角CSS | 圆角 (CSS | Rounded Corners) border-radius property is commonly used to convert box elements into circles. We can convert box elements into the circle element by setting the border-radius to half of the length of a square element.…

iti axi dsp_ITI的完整形式是什么?

iti axi dspITI&#xff1a;工业培训学院 (ITI: Industrial Training Institute) ITI is an abbreviation of the Industrial Training Institute. It offers training in engineering and non-engineering technical fields. It is a post-secondary school in India which is…

appweb ejs_具有快速路线的EJS

appweb ejsHI! Welcome to NODE AND EJS TEMPLATE ENGINE SERIES. Today, we will see how we can work with EJS and routes? 嗨&#xff01; 欢迎使用NODE和EJS模板引擎系列 。 今天&#xff0c;我们将看到如何使用EJS和路由&#xff1f; A route is like a sub domain wit…

ups一直响是什么原因_UPS的完整形式是什么?

ups一直响是什么原因UPS&#xff1a;不间断电源 (UPS: Uninterruptible Power Supply) UPS is an abbreviation of Uninterruptible Power Supply. It operates with the support of a battery which is used to supply power in the lack of most important source or when th…

语音asr是什么意思_ASR的完整形式是什么?

语音asr是什么意思ASR&#xff1a;自动语音识别 (ASR: Automated Speech Recognition) ASR stands for Automated Speech Recognition. With the help of this technology, spoken words can be easily converted to written text. What actually it does? It gives access to…

数据库缓冲池_块缓冲| 数据库管理系统

数据库缓冲池When several blocks need to be transferred from disk to main memory and all the block addresses are known, several buffers can be reserved in main memory to speed up the transfer. 当需要将几个块从磁盘传输到主存储器并且所有块地址已知时&#xff0…

递归如何书写?

目录 第一步&#xff1a;首先你分析问题&#xff0c;要有递归的思路&#xff0c;知道要递归什么来解决问题。 第二步&#xff1a;先按照思路&#xff08;第一层&#xff09;写出函数的定义与函数体 第三步&#xff1a;根据函数的定义与函数体进一步确定需要的参数 第四步&a…

python 散点图 分类_Python | 分类图

python 散点图 分类Visualizing different variables is also a part of basic plotting. Such variables can have different classes, for example, numerical or a category. Matplotlib has an important feature of Categorical Plotting. We can plot multiple categoric…

二叉树祖先节点_二叉树的祖先

二叉树祖先节点Problem statement: 问题陈述&#xff1a; Given a Binary Tree and a target key, write a function that prints all the ancestors of the key in the given binary tree. 给定二叉树和目标键&#xff0c;编写一个函数&#xff0c;以打印给定二叉树中键的所有…

CALayer精讲

CALayer精讲 CALayer包含在QuartzCore框架中&#xff0c;这是一个跨平台的框架&#xff0c;既可以用在iOS中又可以用在Mac OS X中。后面要学Core Animation就应该先学好Layer&#xff08;层&#xff09;。 我们看一下UIView与Layer之间的关系图&#xff08;图片来源于网络&…

rofl用什么播放_ROFL的完整形式是什么?

rofl用什么播放ROFL&#xff1a;笑在地板上滚动 (ROFL: Rolling On Floor Laughing) ROFL is an abbreviation of Rolling on Floor Laughing. ROFL is a very trendy internet slang between youngsters and used in text messaging, instant messaging, chatting, and social…

gif 格式 完整 检查_GIF的完整格式是什么?

gif 格式 完整 检查GIF&#xff1a;图形交换格式 (GIF: Graphics Interchange Format) GIF is an abbreviation of Graphics Interchange Format. It is extensively used for animations and still images on the World Wide Web. The image is set out is bitmap image and i…