


Dear netizens, in today’s article, I will lead you step by step in developing the "Hot News Search Words" special effect on Baidu News homepage. The knowledge points applied in this special effect are very basic. If you are still unclear about these, you can follow the detailed tutorials I wrote before. When I talk about this case today, I also want to tell everyone that when developing a special effect, please don’t complicate the problem. Maybe some people really don’t know where to start at the beginning, but after you finish reading this tutorial, you will definitely feel that everything is so simple.
Maybe some people don’t know this special effect yet, so I won’t say anything more and just go to the renderings:
From the above special effects, it is not difficult to find that when When the mouse moves over the hot search words, a translucent black background will slide up, and there are also hot search words in this black area.
After roughly knowing these details, I will now lead you step by step in developing this special effect.
Based on the key details mentioned above, write the html code as follows:
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="styles.css"> <title>CSS3实战开发:百度热搜词动画特效实战开发</title> </head> <body> <div class="container"> <div id="news_hotwords"> <div class="keywords_title"> <a href="http://www.itdriver.cn">新闻热搜词</a><span>HOT WORDS</span> </div> <div class="hotwords"> <ul> <li class="li_0 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn" title="css3教程,html5教程,互联网实战教程">一起为改革发力</a> <a class="detail" href="http://www.itdriver.cn" title="css3教程,html5教程,互联网实战教程">一起为改革发力</a> </li> <li class="li_1 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">习 近 平会见外国友人</a> <a class="detail" href="http://www.itdriver.cn">习 近 平会见外国友人</a> </li> <li class="li_2 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn">李 克 强重视知识产权</a> <a class="detail" href="http://www.itdriver.cn">李 克 强重视知识产权</a> </li> <li class="li_3 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">36斤纯黄金鸳鸯枕</a> <a class="detail" href="http://www.itdriver.cn">36斤纯黄金鸳鸯枕</a> </li> <li class="li_4 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn">EXO机场辱工作人员</a> <a class="detail" href="http://www.itdriver.cn">EXO机场辱工作人员</a> </li> <li class="li_5 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">学费迎来"涨价潮"</a> <a class="detail" href="http://www.itdriver.cn">学费迎来"涨价潮"</a> </li> <li class="li_6 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn">女举小将蒋惠花夺魁</a> <a class="detail" href="http://www.itdriver.cn">女举小将蒋惠花夺魁</a> </li> <li class="li_7 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">童名谦获刑五年</a> <a class="detail" href="http://www.itdriver.cn">童名谦获刑五年</a> </li> <li class="li_8 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn">青奥会</a> <a class="detail" href="http://www.itdriver.cn">青奥会</a> </li> <li class="li_9 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">白卷英雄成4亿富豪</a> <a class="detail" href="http://www.itdriver.cn">白卷英雄成4亿富豪</a> </li> <li class="li_10 li_color_0"> <a class="hotwords_li_a" href="http://www.itdriver.cn">被俘虏女子拒做性奴</a> <a class="detail" href="http://www.itdriver.cn">被俘虏女子拒做性奴</a> </li> <li class="li_11 li_color_1"> <a class="hotwords_li_a" href="http://www.itdriver.cn">女子把狗毛当零食</a> <a class="detail" href="http://www.itdriver.cn">女子把狗毛当零食</a> </li> </ul> </div> </div> </div> </body></html>
You will find from the html source code that two hot search terms appear This is because one is used for normal display and the other is used for the black area that slides up when the mouse is moved over. Here I will temporarily define their styles as .hotwords_li_a and detail, and our keywords will be displayed using an unordered list (ul).
After the page code is written, let’s run it first to see the current effect:
After the page elements are ready, then we add styles to the page. First What we need to do is to first clear the default style of the unordered list (ul), and set the outer container layout to facilitate demonstration. The style code is as follows:
*{ /*设置所有元素默认内外边距,同时设置默认字体大小*/ margin:0; padding:0; font-size:14px;}.container{ /*设置外层容器布局,这里主要是为了方便演示*/ margin:200px 200px auto;}/*清除ul默认显示样式*/ul { list-style-type:none; }a { /*去除超链接下划线*/ text-decoration:none; }
Run the page to see the page effect at this time:
The basic layout of the outer container and the layout of all elements After the default style setting is completed, now we can implement the regional style of hot news search words:
.hotwords li{ float:left; /*使热搜词都向左浮动*/ position:relative; /*由于li里面有元素要执行动画效果,所以将li的position设置为相对定位*/ width:68px; /*设置热搜词的基本宽高度*/ height:68px; margin:0 2px 2px 0; overflow:hidden; /*设置当热搜词显示的内容超过区域大小时,隐藏超出的部分*/ text-align:center; /*内部文字居中显示*/}.hotwords li.li_0,.hotwords li.li_3,.hotwords li.li_8,.hotwords li.li_11 { /*大家访问百度新闻首页,定会发现,它的1,4,9和12这几个快的宽度是其他的两倍,所以这里单独设置*/ width:138px;}.hotwords li a{ /*将所有a元素都设置为块元素block,这样就可以调整它的高度*/ display:block; text-decoration:none; padding:2px; height:64px; color:white;}.hotwords li.li_0 a,.hotwords li.li_3 a,.hotwords li.li_8 a,.hotwords li.li_11 a { /*对于1,4,9和12这几个元素它的文字是垂直方向上居中显示的*/ width:135px; line-height:64px;}.hotwords li.li_color_0{ background:#0DA4D6;}.hotwords li.li_color_1{ background:#35C4EF;}
The above style code is mainly to set For the style of the hot search word area li, if you don’t know much about the code, you can refer to my style comments.
The effect at this time is as follows:
You can find that in the style I demonstrated at the beginning, the title information of the hot news search term is light blue, and at the same time The hot search word area displays two lines. Now let’s add the following settings to display the style of the hot search word area:
.hotwords{ /*设置新闻热搜词区域的大小*/ width:568px;}.keywords_title{ /*设置热搜词区域字体样式以及它距离底部外边距的距离*/ font-size:1.5em; margin-bottom:10px;}.keywords_title,.keywords_title a{ /*设置热搜词title以及热搜词link的默认颜色*/ color:#3399CC;}
The page style at this time is as follows:
When we mouse over these hot search terms, nothing changes. Okay, then we apply styles to the elements of type detail on the page:
.hotwords .detail{ position:absolute;/*设置detail为绝对定位,由于li设置了relative,所以detail是相对于li元素的绝对定位*/ background:rgba(0,0,0,0.8); /*设置detail区域的背景色*/ left:0; /*设置detail相对li的偏移距离*/ top:68px; -webkit-transition:top 0.2s; /*当detail类型的元素top属性发生变化时,执行过度动画,过度时间为0.2s*/ -moz-transition:top 0.2s; -o-transition:top 0.2s; transition:top 0.2s;}.hotwords li:hover .detail{ /*当鼠标划过li时,设置detail类型元素的样式*/ top:0px;}
In the above code, we mainly use two key attributes, position:absolute and transition. If you don’t know much about these two, you can refer to the tutorials I wrote before "CSS3 Practical Development: Teach You Step by Step Practical Development of Photo Walls" and "CSS3 Basic Properties of Transition Detailed explanation》. After studying these two tutorials, I believe you will be familiar with these knowledge points.
Now let’s run the page:
At this point, the "Baidu News Hot Search Words Special Effect" has been developed. Isn’t it very simple?
A list of exciting practical development cases in the past ( has been widely reproduced, only some are listed below ):
1. "CSS3 practical development: step by step Teach you the development of mouse sliding special effects》
2. "CSS3 practical development: teach you step by step the practical development of search form lighting special effects"
3. "CSS3 Practical Development: Responsive WEB Interface Design of Flexible Box Model"
4. "CSS3 Linear Gradient Technology Detailed Explanation and Stunning Button Practical Development"
5. "CSS3 2D conversion - detailed explanation of translate technology and practical development of web navigation"
6. "CSS3 practical development: teach you step-by-step practical development of photo wall"
7. 《CSS3 practical development: teach you step by step how to develop mouse-over picture animation special effects》
8. 《CSS3 practical development: imitating Tmall Home page picture shows practical development of animation special effects》
9. 《CSS3 practical development: teach you step by step the practical development of folding effect》
Welcome everyone to join Internet technology exchange group: 62329335
Personal statement: The blog posts shared are absolutely original, and we strive to verify every knowledge point through practical demonstrations.

如何使用Vue实现弹出窗口特效,需要具体代码示例近年来,随着Web应用的发展,弹出窗口特效已经成为广大开发者常用的交互方式之一。Vue作为一款流行的JavaScript框架,提供了丰富的功能和易用性,非常适合用来实现弹出窗口特效。本文将介绍如何使用Vue实现弹出窗口特效,并提供具体代码示例。首先,我们需要使用Vue的CLI工具来创建一个新的Vue项目。打开终

如何使用Vue实现全屏遮罩特效在Web开发中,我们经常会遇到需要全屏遮罩的场景,比如在加载数据时显示一个遮罩层以阻止用户进行其他操作,或者在某些特殊场景下需要用遮罩层来突出显示某个元素。Vue是一个流行的JavaScript框架,它提供了方便的工具和组件来实现各种效果。在本文中,我将介绍如何使用Vue来实现全屏遮罩的效果,并提供一些具体的代码示例。首先,我们

如何使用Vue实现侧边栏特效Vue是一款流行的JavaScript框架,它的简单易用和灵活性使开发人员能够快速构建交互性强的单页面应用程序。在这篇文章中,我们将学习如何使用Vue来实现一个常见的侧边栏特效,同时提供具体的代码示例帮助我们更好地理解。创建Vue项目首先,我们需要创建一个Vue项目。可以使用Vue提供的VueCLI(命令行界面),它能够快速生成

实现微信小程序中的卡片翻转特效在微信小程序中,实现卡片翻转特效是一种常见的动画效果,可以提升用户体验和界面交互的吸引力。下面将具体介绍如何在微信小程序中实现卡片翻转的特效,并提供相关代码示例。首先,需要在小程序的页面布局文件中定义两个卡片元素,一个用于显示正面内容,一个用于显示背面内容,具体示例代码如下:<!--index.wxml-->&l

HTML、CSS和jQuery:实现图片折叠展开特效的技巧介绍在网页设计和开发中,我们经常需要实现一些动态特效来增加页面的吸引力和交互性。其中,图片折叠展开特效是一种常见但又很有趣的技巧。通过这种特效,我们可以让图片在用户的操作下折叠或展开,从而展示更多的内容或细节。本文将介绍如何使用HTML、CSS和jQuery来实现这种效果,并附上具体的代码示例。实现思

如何使用Vue实现进度条特效进度条是常见的一种界面元素,它可以用来展示一个任务或操作的完成情况。在Vue框架中,我们可以通过一些简单的代码实现进度条的特效效果。本文将介绍如何使用Vue来实现进度条特效,并提供具体代码示例。创建Vue组件首先,我们需要创建一个Vue组件来实现进度条的功能。在Vue中,组件是可以复用的,我们可以在多个地方使用。创建一个名为Pro

如何使用Vue实现视频播放器特效摘要:本文将介绍如何使用Vue.js框架实现一个带有各种特效的视频播放器。我们将使用Vue指令和组件来实现播放/暂停按钮、进度条、音量控制以及全屏功能。同时,我们还将添加一些动画效果来增强用户体验。下面将针对不同的特效分别进行详细介绍,包括代码示例。播放/暂停按钮特效:使用Vue指令来实现播放/暂停按钮特效是非常简单的。首先,

如何使用Vue实现返回顶部特效引言:在现代网页设计中,返回顶部按钮是一个常见的功能,它给用户提供了便捷的操作,使用户能够轻松地返回页面的顶部。本文将介绍如何使用Vue框架来实现这个功能,并提供具体的代码示例。一、创建Vue项目:首先,我们需要创建一个Vue项目,可以使用VueCLI来快速创建。打开终端,执行以下命令:vuecreateback-to-t


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.