Home Web Front-end HTML Tutorial CSS一级导航-天蓝色(带阴影)_html/css_WEB-ITnose

CSS一级导航-天蓝色(带阴影)_html/css_WEB-ITnose

Jun 24, 2016 am 11:33 AM

一款亮丽的导航,能给网站一个画龙点睛的作用。导航在指引用户搜寻内容时,还能改变用户浏览网站的心情,浏览网站也像一场旅行,有创意的导航栏让用户欣赏起来也会更加愉悦,增加对网站的兴趣。

本人不擅长美工制作,不过可以从某些漂亮的网站中提取不错的部分为自己所用,也为他人分享。今天这里为大家准备了一款天蓝色导航一起学习。

我们先看最终效果:



第一步:放置一个div作为导航主体部分

<div class="userPlaceMain"></div>
Copy after login

为其编写样式:

.userPlaceMain {    clear: both;    width:1200px    height: 50px;    line-height: 50px;    background: #0090CE;    padding: 0 20px;    color: White;    -moz-box-shadow: 5px 5px 10px #B7B7B7;    box-shadow: 5px 5px 10px #B7B7B7;}
Copy after login

注意:此处-moz-box-shadow: 5px 5px 10px #B7B7B7; box-shadow: 5px 5px 10px #B7B7B7;为导航阴影部分

此时导航效果如下:



第二步:放置导航链接内容

这里使用ul li无序列表

<ul>     <li><a id="userPlaceId_1" href="http://xunwn.com/1010100" class="userPlaceMainUlLiHover">主页</a>|</li>     <li><a id="userPlaceId_2" href="http://xunwn.com">形象展示</a>|</li>     <li><a id="userPlaceId_3" href="http://xunwn.com/photo/1010100">产品展示</a></li></ul>
Copy after login


现在需要将ul li向左浮动,使用:float:left

.userPlaceMain ul li {    float: left;    margin-right: 10px;}
Copy after login

此时导航效果如下:



离我们最后的效果不远了,还差设置链接文字宽度、背景、间隔

第二步:设置链接文字宽度、背景、间隔

由于a标记为内联标记,若需设置宽度需要使用其他处理方式,这里使用display:inline-block即可设置宽度

.userPlaceMain ul li a {    text-shadow: 0 1px 0 rgba(0,0,0,0.3);    color: White;    display: inline-block;    width: 100px;    height: 100%;    font-size: 15px;    text-align: center;    margin-right: 10px;}
Copy after login


注意: text-shadow: 0 1px 0 rgba(0,0,0,0.3);是为文字增加阴影,此项可不设置

此时导航效果如下:



现在效果好多了吧,还差最后一点处理,就是导航鼠标滑动样式

第三步:设置导航鼠标滑动样式

这里有两种方式,一:直接使用css伪类选择器:hover;二:javascript或者juqery控制链接文字css样式,这里使用第一种,更加简便

.userPlaceMain ul li a:hover{background: #0074A6;color:White; }
Copy after login


最终效果如下:



本人向来追求简单时尚的做法,以后有空还会做更多的东西一起分享,大家一起来学习吧,OK今天告一段落,thank you!

 

原文地址: http://xunwn.com/tgzp/1010100_6751

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles