search
HomeWeb Front-endH5 TutorialHow to create a three-dimensional navigation bar with CSS


<!doctype html><html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>CSS制作立体导航</title>
        <link rel="stylesheet" href="http://www.w3cplus.com/demo/css3/base.css">
        <style>
            body{
              background: #ebebeb;
            }
            .nav{
              width:560px;
              height: 50px;
              font:bold 0/50px Arial;
              text-align:center;
              margin:40px auto 0;
              background: #f65f57;
             /*制作导航圆角*/
              border-radius: 8px;
             /*制作导航立体效果*/
              box-shadow: 0 7px 0 #ba4a45;
            }
            .nav a{
              display: inline-block;
              /* a元素的过渡属性:1、设置所有a标签过渡;2、过渡时间;3、速度曲线:以慢速开始的过渡效果 */
                -webkit-transition: all 0.2s ease-in;/* Safari 和 Chrome */
                -moz-transition: all 0.2s ease-in;/* Firefox */
               -o-transition: all 0.2s ease-in;/* Opera */
               -ms-transition: all 0.2s ease-in;/* IE 9 */
               transition: all 0.2s ease-in;
            }
            .nav a:hover{
                /* 鼠标移上时的效果;定义2D旋转10度 */
              -webkit-transform:rotate(10deg);
              -moz-transform:rotate(10deg);
              -o-transform:rotate(10deg);
              -ms-transform:rotate(10deg);
              transform:rotate(10deg);
            }

            .nav li{
              position:relative;
              display:inline-block;
              padding:0 16px;
              font-size: 14px;
              text-shadow:1px 2px 4px rgba(0,0,0,.5);
              list-style: none outside none;
            }
            /*制作导航分隔线效果*/
            .nav li::before,
            .nav li::after{
              content:"";
              position:absolute;
              top:14px;
              height: 25px;
              width: 1px;
            }
            .nav li::after{
              right: 0;
              /* 线性渐变 */
              background: -moz-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
              background: -webkit-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
              background: -o-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
              background: -ms-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
              background: linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
            }
            .nav li::before{
              left: 0;
              background: -moz-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
              background: -webkit-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
              background: -o-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
              background: -ms-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
              background: linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
            }
            /*删除导航第一个导航项左边的分隔线*/
            .nav li:first-child::before{
              background: none;
            }
            /*删除导航最后一个导航右边的分隔线*/
            .nav li:last-child::after{
              background: none;
            }
            .nav a,
            .nav a:hover{
              color:#fff;
              text-decoration: none;
            }

        </style>
    </head>
    <body>
        <ul class="nav">
        <li><a href="">首页</a></li>
        <li><a href="">个人简介</a></li>
        <li><a href="">作品集</a></li>
        <li><a href="">博客</a></li>
        <li><a href="">资源</a></li>
        <li><a href="">联系我</a></li>
        </ul>
    </body></html>

Rendering:

1

##2

Summary:

1. Use an unordered list for the body part

2. (1)hover

  The effect when the mouse is moved up.

 (2) Question

The difference between::before and :before

    Simply put, single colon (:) is used for CSS3 pseudo-classes, and the double colon (::) is used for CSS3 pseudo-elements.

   w3c specification on css selector:

A pseudo-element is made of two colons (

::) followed by the name of the pseudo-element.

This

:: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in CSS level 3. composition. The double colon was introduced in the current specification to distinguish pseudo-classes from pseudo-elements. However, the browser needs to support the old existing pseudo-element writing methods at the same time, such as: first-line, :first-letter, :before, :after, etc., while the new pseudo-elements introduced in CSS3 are not allowed

Supports the old single colon writing method.

Now you can fully answer the question in the title. For the pseudo-elements that existed before CSS2, such as :before, the single colon and double colon are written in::beforeThe effect is the same.

Therefore, if your website only needs to be

compatible with webkit, firefox, opera and other browsers, it is recommended to use double colon writing for pseudo elements. If it must be compatible In IE browser, it is safer to use CSS2 single colon writing method.

The above is the detailed content of How to create a three-dimensional navigation bar with CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
H5: New Features and Capabilities for Web DevelopmentH5: New Features and Capabilities for Web DevelopmentApr 29, 2025 am 12:07 AM

H5 brings a number of new functions and capabilities, greatly improving the interactivity and development efficiency of web pages. 1. Semantic tags such as enhance SEO. 2. Multimedia support simplifies audio and video playback through and tags. 3. Canvas drawing provides dynamic graphics drawing tools. 4. Local storage simplifies data storage through localStorage and sessionStorage. 5. The geolocation API facilitates the development of location-based services.

H5: Key Improvements in HTML5H5: Key Improvements in HTML5Apr 28, 2025 am 12:26 AM

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

HTML5: The Standard and its Impact on Web DevelopmentHTML5: The Standard and its Impact on Web DevelopmentApr 27, 2025 am 12:12 AM

The core features of HTML5 include semantic tags, multimedia support, offline storage and local storage, and form enhancement. 1. Semantic tags such as, etc. to improve code readability and SEO effect. 2. Simplify multimedia embedding with labels. 3. Offline storage and local storage such as ApplicationCache and LocalStorage support network-free operation and data storage. 4. Form enhancement introduces new input types and verification properties to simplify processing and verification.

H5 Code Examples: Practical Applications and TutorialsH5 Code Examples: Practical Applications and TutorialsApr 25, 2025 am 12:10 AM

H5 provides a variety of new features and functions, greatly enhancing the capabilities of front-end development. 1. Multimedia support: embed media through and elements, no plug-ins are required. 2. Canvas: Use elements to dynamically render 2D graphics and animations. 3. Local storage: implement persistent data storage through localStorage and sessionStorage to improve user experience.

The Connection Between H5 and HTML5: Similarities and DifferencesThe Connection Between H5 and HTML5: Similarities and DifferencesApr 24, 2025 am 12:01 AM

H5 and HTML5 are different concepts: HTML5 is a version of HTML, containing new elements and APIs; H5 is a mobile application development framework based on HTML5. HTML5 parses and renders code through the browser, while H5 applications need to run containers and interact with native code through JavaScript.

The Building Blocks of H5 Code: Key Elements and Their PurposeThe Building Blocks of H5 Code: Key Elements and Their PurposeApr 23, 2025 am 12:09 AM

Key elements of HTML5 include,,,,,, etc., which are used to build modern web pages. 1. Define the head content, 2. Used to navigate the link, 3. Represent the content of independent articles, 4. Organize the page content, 5. Display the sidebar content, 6. Define the footer, these elements enhance the structure and functionality of the web page.

HTML5 and H5: Understanding the Common UsageHTML5 and H5: Understanding the Common UsageApr 22, 2025 am 12:01 AM

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

HTML5: The Building Blocks of the Modern Web (H5)HTML5: The Building Blocks of the Modern Web (H5)Apr 21, 2025 am 12:05 AM

HTML5 is the latest version of the Hypertext Markup Language, standardized by W3C. HTML5 introduces new semantic tags, multimedia support and form enhancements, improving web structure, user experience and SEO effects. HTML5 introduces new semantic tags, such as, ,, etc., to make the web page structure clearer and the SEO effect better. HTML5 supports multimedia elements and no third-party plug-ins are required, improving user experience and loading speed. HTML5 enhances form functions and introduces new input types such as, etc., which improves user experience and form verification efficiency.

See all articles

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor