当前位置:首页 > 建站教程 > html+css+js实现网页中广告块代码

html+css+js实现网页中广告块代码

2年前 (2024-08-21)建站教程500
html+css+js实现网页中广告块代码

工具/原料

  • adobe dreamweaver

方法/步骤

  1. 新建html文档。
    html+css+js实现网页中广告块代码
  2. 书写hmtl代码。 <div id = "wrap"> <ul> <li class = "liA"> <div class = "divA"></div> <a href="">11111111111111<br>11111111111111</a> <div class = "divA1"></div> </li> <li  class = "liA"> <div class = "divA"></div> <a href="">11111111111111<br>11111111111111</a> <div class = "divA2"></div> </li> <li  class = "liB"> <div class = "divA"></div> <a href="">11111111111111</a> <div class = "divA1"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="" class = "aa" >11111111111111</a> <div class = "divA1"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="">11111111111111<br> 11111111111111</a> <div class = "divA2"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="" class = "aa">11111111111111</a> <div class = "divA1"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="" class = "aa">11111111111111</a> <div class = "divA2"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="">11111111111111</a> <div class = "divA1"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="">1111111111111<br> G20</a> <div class = "divA1"></div> </li> <li class = "liB"> <div class = "divA"></div> <a href="">1111111111111<br> 1111111111111</a> <div class = "divA2"></div> </li> </ul> </div>
    html+css+js实现网页中广告块代码
  3. 书写css代码。 <style> * { margin: 0; padding: 0; } a { text-decoration: none; } #wrap { width: 570px; height: 190px;margin: 100px auto; } ul li { list-style: none; } ul .liA { width: 188px; height: 88px; background: rgb(40,100,187); ; float: left; margin: 1px; position: relative; z-index: 5; overflow: hidden; } ul .liB { width: 93px; height: 88px; background: rgb(40,100,187); ; float: left; margin: 1px; position: relative; z-index: 5; overflow: hidden; } ul .liA a { font-family: arial, 'Hiragino Sans GB', 'Microsoft Yahei', 微软雅黑, 宋体, Tahoma, Arial, Helvetica, STHeiti; display: inline-block; width: 170px; height: 38px; text-align: center; color: white; position: absolute; top: 17px; left: 5px; } ul .liB a { font-family: arial, 'Hiragino Sans GB', 'Microsoft Yahei', 微软雅黑, 宋体, Tahoma, Arial, Helvetica, STHeiti; font-size: 12px; display: inline-block; width: 93px; height: 30px; text-align: center; color: white; position: absolute; top: 25px; left: 2px; } ul .liB .aa, ul .liA .aa { top: 35px } .divA { position: absolute; width: 100%; height: 100%; top: -100%; left: 0; background: #85a9e8; z-index: 0; } .divA1 { position: absolute; width: 100%; height: 100%; top: 100%; left: 0; background: #3046bb; opacity: 0.2; z-index: 0; } .divA2 { position: absolute; width: 100%; height: 100%; top: 0%; left: 0; background: white; opacity: 0.4; } </style>
    html+css+js实现网页中广告块代码
  4. 书写并添加js代码。 <script src="jquery/jquery-2.2.4.min.js"></script> <script> $(document).ready(function(){ $('.divA1').eq($(this).index()).animate({top:'0'},5) }) $('li').mouseenter(function(){ $(this).css('background-color','rgb(24,68,142)') $('.divA').eq($(this).index()).animate({top:'0'},300) $('.divA').eq($(this).index()).animate({top:'100%'},150) $('.divA1').eq($(this).index()).animate({top:'100%'},150) $(this).find('.divA2').animate({top:'100%'},300) }) $('li').mouseleave(function(){ $('.divA1').eq($(this).index()).animate({top:'0'},150) $('.divA').eq($(this).index()).animate({top:'-100%'},10) $(this).find('.divA2').animate({top:'0'},150) $(this).css('background','rgb(40,100,187)') })   </script>
    html+css+js实现网页中广告块代码
  5. 代码整体结构。
    html+css+js实现网页中广告块代码
  6. 查看效果。
    html+css+js实现网页中广告块代码
    END

扫描二维码推送至手机访问。

欢迎转载或分享本篇文章。

本文链接:https://www.jcba123.com/article/9785

分享给朋友:

“html+css+js实现网页中广告块代码” 的相关文章

WordPress网站加速指南:快如闪电

WordPress网站加速指南:快如闪电

关于WordPress网站速度问题,总有人抱怨说慢。但是如果真的慢的话,为什么会有那么多人用呢?其实不然,WordPress建站速度并不慢,慢是因为选择的主题不对。很多人使用国外WorPress主题,因为功能强,设计漂亮时尚。但是在你使用WordPress主题时,有没有考虑到主题的使用环境?首先优化...

如何优化 WordPress SEO——详细的分步指南

如何优化 WordPress SEO——详细的分步指南

WordPress SEO,是容易还是难?对很多人来说,登上 Google 的首页可能听起来像是一厢情愿,有些人甚至会告诉你这是不可能的。 我们在这里告诉你不同的。您可以在搜索引擎结果页面 (SERP) 中脱颖而出,我们在这里告诉您如何做。 在这篇文章中,我们将解释什么是搜索引擎优化 (...

使用 WP Downgrade 在线降级 WordPress 到旧版本!

我们都知道,每当WordPress有新本的时候,我们都可以在后台一键更新。但是有些时候,我们的主题或插件可能不兼容新版本的WP,这时候我们如果要降级为之前的旧版本,该怎么操作呢?下面一起来看看。 重要提示:不管是升级还是降级,操作前,请务必备份你的网站数据,尤其是网站的数据库,以防万一!...

介绍使用WordPress时10个常用的MySQL查询

多数使用 WordPress 搭建的网站,其后台都是 MySQL 数据库,经常我们需要定制 WordPress 的功能,这里我们列表 10 个最有用的 WordPress 的数据库查询,你需要一个数据库的管理工具,例如 phpMyAdmin 或者 Navicat 等来执行这些 SQL 语句。...

8个好用的WordPress RSS Feed插件

8个好用的WordPress RSS Feed插件

什么是RSS Feed? RSS代表“Really Simple Syndication”,但它也可能意味着“丰富站点摘要”或“实时简单联合组织”。这是一种基于XML的内容格式,可向用户更新所有他们喜欢的网站上的最新新闻,文章,标题和内容。 由于已经存在了很长一段时间,因此许多人都认为RSS...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。