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

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

2年前 (2024-08-21)建站教程670
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主题吗?关于这个问题,我当时的回答是采用WordPress多站点模式。后来仔细想了下,WordPress多站是基于用户选择不同的WordPress主题,和这位用户问的还是不同的。今天回来,仔细研究...

wordpress如何显示全部文章的总浏览数

wordpress如何显示全部文章的总浏览数,下面web建站小编给大家详细介绍一下具体实现方法! 打开主题下functions.php,新增以下代码: function article_all_view(){ global $wpdb; $count=0; $views...

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

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

WordPress 如何批量修改文章信息?

你是否遇到过如下几种状况: 博客更换域名,博客文章的内容也要跟着换 使用的图片地址更换了 写了很多文章,回过头来想切换作者 想删除某个可恶留言者的所有留言 想更改某个留言者所有留言的网站URL 想要禁用所有文章的pingback 想要禁用所有文章的评...

介绍使用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...

发表评论

访客

看不清,换一张

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