search
HomeWeb Front-endHTML TutorialCSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose

Hello netizens, today I will lead you to develop a pure CSS image classification display URL navigation. You may be a little confused just by looking at the title. According to past practice, I will first demonstrate the actual operation effect for you:

From the above operation effect, it is not difficult to find that when I click on a menu, the navigation area will highlight the icons of this category accordingly, while other icons will dim .

Many people may say that this is so simple. You can quickly achieve the same effect by directly using front-end frameworks such as javascript or jQuery and some CSS. If you are one of these people, I also hope you will stop and read this tutorial. Because in today's tutorial, I will use another way of thinking to think about the problem. I will lead you to completely break away from js and how to achieve switching effects and image classification, aiming to teach you an idea.

Okay, no more nonsense, let’s start today’s practical development tutorial.

First, we define the html page. The code is as follows (for the convenience of demonstration, I directly imported the styles.css file. At this time, the file does not have any style content):

<!DOCTYPE html><html>    <head>        <meta charset="utf-8">        <link rel="stylesheet" href="styles.css">        <title>CSS3实战开发:图片过滤分类特效</title>    </head>    <body>        <div class="container">        <div class="hot_navs">            <div class="hot_title">                <input id="selector-type-all" type="radio" name="title_set" class="selector-type-all" checked="checked" />                <label for="selector-type-all" class="label-type-all">全部类别</label>                                <input id="selector-type-1" type="radio" name="title_set" class="selector-type-1" />                <label for="selector-type-1" class="label-type-1">电子商务</label>                                <input id="selector-type-2" type="radio" name="title_set" class="selector-type-2" />                <label for="selector-type-2" class="label-type-2">旅游</label>                                <input id="selector-type-3" type="radio" name="title_set" class="selector-type-3" />                <label for="selector-type-3" class="label-type-3">社交</label>                                <input id="selector-type-4" type="radio" name="title_set" class="selector-type-4" />                <label for="selector-type-4" class="label-type-4">视频</label>                                <input id="selector-type-5" type="radio" name="title_set" class="selector-type-5" />                <label for="selector-type-5" class="label-type-5">新闻</label>                                <input id="selector-type-6" type="radio" name="title_set" class="selector-type-6" />                <label for="selector-type-6" class="label-type-6">信息门户</label>                                <input id="selector-type-7" type="radio" name="title_set" class="selector-type-7" />                <label for="selector-type-7" class="label-type-7">票务</label>                <div class="splitline"></div>                <a class="item-type-1" href="http://www.itdriver.cn">                    <img  src="/static/imghwm/default1.png"  data-src="imgs/101.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-1" href="http://www.itdriver.cn">                    <img  src="/static/imghwm/default1.png"  data-src="imgs/102.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-7" href="http://www.itdriver.cn">                        <i></i>                    <img  src="/static/imghwm/default1.png"  data-src="imgs/103.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                        <img  src="/static/imghwm/default1.png"  data-src="imgs/104.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-5" href="http://www.itdriver.cn">                        <img  src="/static/imghwm/default1.png"  data-src="imgs/105.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-4" href="http://www.itdriver.cn">                    <img  src="/static/imghwm/default1.png"  data-src="imgs/106.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-3" href="http://www.itdriver.cn">                        <i></i>                    <img  src="/static/imghwm/default1.png"  data-src="imgs/107.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-4" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/108.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-3" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/109.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-3" href="http://www.itdriver.cn">                        <i></i>                    <img  src="/static/imghwm/default1.png"  data-src="imgs/110.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                        <i></i>                    <img  src="/static/imghwm/default1.png"  data-src="imgs/111.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/112.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/113.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/114.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-1" href="http://www.itdriver.cn">                        <i></i>                    <img  src="/static/imghwm/default1.png"  data-src="imgs/115.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-5" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/116.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-6" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/117.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>                <a class="item-type-2" href="http://www.itdriver.cn">                    <i></i>                        <img  src="/static/imghwm/default1.png"  data-src="imgs/118.png"  class="lazy"  / alt="CSS3 practical development: Pure CSS to implement image filtering, classification and display effects_html/css_WEB-ITnose" >                </a>            </div>        </div>    </div>        </body></html>

You will find from the above html code that my navigation menu uses label or radio tags. Why should I define them? Because I want to know which menu I currently clicked, because with CSS alone, we It seems that there is no way to know who is currently clicked, so when I click on the Label, a certain radio will be automatically selected.

At this point, let’s run the page to see how it works without adding any styles:

First, let’s adjust the size of the navigation area and add The border and style code are as follows:

*{ /*设置页面基本属性*/    margin:0;    padding:0;    font-size:14px;}.container{ /*调整外围容器布局*/    margin:200px auto;    width:1024px;}.hot_navs{ /*设置分类导航样式*/    border:1px solid #CCCCCC;    padding:.5em;    width:725px;}

The page effect at this time is as follows:

The size of the area has been determined, now we need to Set styles for the navigation menu, hide the radio buttons, and set the dividing line between the menu and the chart:

/*分割线*/.hot_navs .splitline { margin-bottom:4px;height:1px;border-top:1px dotted #999999; }.hot_navs a{ /*设置导航item的基本样式*/    text-decoration:none;    display:inline-block;    height:70px;    line-height:70px;    position:relative;    background:#FFE500;        -webkit-transition:all 0.6s; /*当item属性发生变化时,执行过度动画*/    -moz-transition:all 0.6s;    -o-transition:all 0.6s;    transition:all 0.6s;}.hot_navs input{display:none;}.hot_navs .label-type-all,.hot_navs .label-type-1,.hot_navs .label-type-2,.hot_navs .label-type-3,.hot_navs .label-type-4,.hot_navs .label-type-5,.hot_navs .label-type-6,.hot_navs .label-type-7 { /*设置区域头部导航菜单的基本样式*/    display:inline-block;    margin-top:10px;    padding:10px 10px;    cursor:pointer;}

The effect is as follows:

Careful netizens will find that I added the transition attribute to the above CSS style. This attribute mainly means that when any attribute of the menu changes, a transition animation is executed.

Next, we add the selected style to the navigation button, and also set the icon opacity of this category to 1 when a menu is selected, and the opacity of other categories to 0.2. The style code is as follows:

.hot_navs input.selector-type-all:checked ~ .label-type-all,.hot_navs input.selector-type-1:checked ~ .label-type-1,.hot_navs input.selector-type-2:checked ~ .label-type-2,.hot_navs input.selector-type-3:checked ~ .label-type-3,.hot_navs input.selector-type-4:checked ~ .label-type-4,.hot_navs input.selector-type-5:checked ~ .label-type-5,.hot_navs input.selector-type-6:checked ~ .label-type-6,.hot_navs input.selector-type-7:checked ~ .label-type-7 { /*设置选择某一菜单时,当前菜单的基本样式*/    font-weight:bold;    border-bottom:2px solid #FF9900;}.hot_navs input.selector-type-all:checked ~ a,.hot_navs input.selector-type-1:checked ~ a.item-type-1,.hot_navs input.selector-type-2:checked ~ a.item-type-2,.hot_navs input.selector-type-3:checked ~ a.item-type-3,.hot_navs input.selector-type-4:checked ~ a.item-type-4,.hot_navs input.selector-type-5:checked ~ a.item-type-5,.hot_navs input.selector-type-6:checked ~ a.item-type-6,.hot_navs input.selector-type-7:checked ~ a.item-type-7 {    opacity: 1;/*当选择某一类别菜单时,设置当前类别item的不透明度*/}.hot_navs input.selector-type-1:checked ~ a:not(.item-type-1),.hot_navs input.selector-type-2:checked ~ a:not(.item-type-2),.hot_navs input.selector-type-3:checked ~ a:not(.item-type-3),.hot_navs input.selector-type-4:checked ~ a:not(.item-type-4),.hot_navs input.selector-type-5:checked ~ a:not(.item-type-5),.hot_navs input.selector-type-6:checked ~ a:not(.item-type-6),.hot_navs input.selector-type-7:checked ~ a:not(.item-type-7) {    opacity: 0.2;/*当选择某一类别菜单时,设置其余类别item的不透明度*/}

At this point, all the style codes for the special effects on this page have been written. I really hope everyone can be inspired, and I also hope you like my tutorial.

Thank you everyone, see you in the next practical development case.

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
HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

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

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

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 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.

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.

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)