效果一:
1.首先,整个底部悬浮通栏广告是固定在浏览器的底部,随着浏览器的滚动,底部悬浮广告始终在浏览器窗口中。这里有几个关键点:通栏,固定,黑色。
所以:首先我们必须给悬浮通栏广告整体一个100%的宽度,其次给它设定固定定位,固定在浏览器底部,背景色为黑色,透明度为0.7。
<span style="color: #008080;">1</span> <span style="color: #800000;">.footfixed</span>{ <span style="color: #008080;">2</span> <span style="color: #ff0000;">width</span>:<span style="color: #0000ff;">100%</span>; <span style="color: #008080;">3</span> <span style="color: #ff0000;">height</span>:<span style="color: #0000ff;">140px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图片大小,宽度必须100% </span><span style="color: #008000;">*/</span> <span style="color: #008080;">4</span> <span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">fixed</span>; <span style="color: #008080;">5</span> <span style="color: #ff0000;">bottom</span>:<span style="color: #0000ff;">0</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">固定定位,固定在浏览器底部。</span><span style="color: #008000;">*/</span> <span style="color: #008080;">6</span> <span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> #081628</span>; <span style="color: #008080;">7</span> <span style="color: #ff0000;">opacity</span>:<span style="color: #0000ff;"> .7</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">Chrome、Safari、Firefox、Opera </span><span style="color: #008000;">*/</span><span style="color: #ff0000;"> <br> filter</span>:<span style="color: #0000ff;">alpha(opacity=70)</span>;<span style="color: #008000;">/*</span><span style="color: #008000;"> 针对 IE8 以及更早的版本 </span><span style="color: #008000;">*/</span> <span style="color: #008080;">8</span> }
2. 底部悬浮通栏广告的图片,可以看出比背景要高(背景height:140px,内图height: 218px)
且整体内容部分居中。
<span style="color: #008080;">1</span> <span style="color: #800000;">.fimg </span>{ <span style="color: #008080;">2</span> <span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;"> 218px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">注意此处图片高度高于140px</span><span style="color: #008000;">*/</span> <span style="color: #008080;">3</span> <span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 1190px</span>; <span style="color: #008080;">4</span> <span style="color: #ff0000;"> margin</span>:<span style="color: #0000ff;"> 0px auto</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">整体内容部分居中</span><span style="color: #008000;">*/</span> <span style="color: #008080;">5</span> }
然而由于底部悬浮广告内容部分高度218px大于设定的父元素的高度140px,高度相差78px
产生如下效果,图片没能完成的展现出来:
这需要图片上移78px,需要对整个底部悬浮广告内容部分整体做相对定位
<span style="color: #008080;">1</span> <span style="color: #800000;">.fimg </span>{ <span style="color: #008080;">2</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> relative</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">父元素相对定位</span><span style="color: #008000;">*/</span> <span style="color: #008080;">3</span> <span style="color: #ff0000;"> top</span>:<span style="color: #0000ff;">-78px</span>; <span style="color: #008080;">4</span> }
结果:
这里有个问题:
图片不是很清楚,因为加了透明度。
解决这个问题,用一个div来设置背景,而不在.footfixed里设置背景色。
1 div class="ftbj">div>
<span style="color: #008080;"> 1</span> <span style="color: #800000;">.ftbj</span>{ <span style="color: #008080;"> 2</span> <span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;">100%</span>; <span style="color: #008080;"> 3</span> <span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;">100%</span>; <span style="color: #008080;"> 4</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> absolute</span>; <span style="color: #008080;"> 5</span> <span style="color: #ff0000;"> top</span>:<span style="color: #0000ff;"> 0</span>; <span style="color: #008080;"> 6</span> <span style="color: #ff0000;"> left</span>:<span style="color: #0000ff;"> 0</span>; <span style="color: #008080;"> 7</span> <span style="color: #ff0000;"> background</span>:<span style="color: #0000ff;">#081628</span>; <span style="color: #008080;"> 8</span> <span style="color: #ff0000;"> opacity</span>:<span style="color: #0000ff;"> .7</span>;<span style="color: #008000;">/*</span><span style="color: #008000;">Chrome、Safari、Firefox、Opera </span><span style="color: #008000;">*/</span><span style="color: #008080;"> <br> 9</span> <span style="color: #ff0000;"> filter</span>:<span style="color: #0000ff;"> alpha(opacity=70)</span>;}<span style="color: #008000;">/*</span><span style="color: #008000;"> 针对 IE8 以及更早的版本 </span><span style="color: #008000;">*/</span> <span style="color: #008080;">10</span> <span style="color: #800000;">.footfixed</span>{ <span style="color: #008080;">11</span> <span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;">100%</span>; <span style="color: #008080;">12</span> <span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;">140px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图片大小,宽度必须100% </span><span style="color: #008000;">*/</span> <span style="color: #008080;">13</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;">fixed</span>; <span style="color: #008080;">14</span> <span style="color: #ff0000;"> bottom</span>:<span style="color: #0000ff;">0</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">固定定位,固定在浏览器底部。</span><span style="color: #008000;">*/</span> <span style="color: #008080;">15</span> }
这样图片效果:
这样就清楚多了。
3.其中关闭按钮的效果:
首先按钮是由图片通过定位实现固定在整个底部悬浮广告图片右上角。需设定图片大小,图片引入路径,需要对整个底部悬浮广告内容部分整体做相对定位,关闭按钮是做绝对定位
<span style="color: #008080;"> 1</span> <span style="color: #800000;">.fimg </span>{ <span style="color: #008080;"> 2</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> relative</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">父元素相对定位</span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 3</span> } <span style="color: #008080;"> 4</span> <span style="color: #800000;">.close </span>{ <span style="color: #008080;"> 5</span> <span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 33px</span>; <span style="color: #008080;"> 6</span> <span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;"> 33px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图片大小 </span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 7</span> <span style="color: #ff0000;"> background</span>:<span style="color: #0000ff;"> url(images/close.png) no-repeat center center</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">图片引入路径 </span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 8</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> absolute</span>; <span style="color: #008080;"> 9</span> <span style="color: #ff0000;"> right</span>:<span style="color: #0000ff;"> 15px</span>; <span style="color: #008080;">10</span> <span style="color: #ff0000;"> top</span>:<span style="color: #0000ff;"> 85px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">通过定位实现固定固定在整个底部悬浮广告图片右上角 </span><span style="color: #008000;">*/</span> <span style="color: #008080;">11</span> }
其次,鼠标移到关闭按钮上,有小手出现,关闭按钮旋转。
为了产生动画效果,加transition
<span style="color: #008080;"> 1</span> <span style="color: #800000;">.close </span>{ <span style="color: #008080;"> 2</span> <span style="color: #ff0000;"> transition</span>:<span style="color: #0000ff;"> .5s</span>; <span style="color: #008080;"> 3</span> <span style="color: #ff0000;"> cursor</span>:<span style="color: #0000ff;"> pointer</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">通过定位实现固定固定在整个底部悬浮广告图片右上角 </span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 4</span> } <span style="color: #008080;"> 5</span> <span style="color: #800000;">.close:hover </span>{ <span style="color: #008080;"> 6</span> <span style="color: #ff0000;"> transform</span>:<span style="color: #0000ff;"> rotate(180deg)</span>; <span style="color: #008080;"> 7</span> <span style="color: #ff0000;"> -ms-transform</span>:<span style="color: #0000ff;"> rotate(180deg)</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> IE 9 </span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 8</span> <span style="color: #ff0000;"> -moz-transform</span>:<span style="color: #0000ff;"> rotate(180deg)</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> Firefox </span><span style="color: #008000;">*/</span> <span style="color: #008080;"> 9</span> <span style="color: #ff0000;"> -webkit-transform</span>:<span style="color: #0000ff;"> rotate(180deg)</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> Safari 和 Chrome </span><span style="color: #008000;">*/</span> <span style="color: #008080;">10</span> <span style="color: #ff0000;"> -o-transform</span>:<span style="color: #0000ff;"> rotate(180deg)</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> Opera </span><span style="color: #008000;">*/</span> <span style="color: #008080;">11</span> } <span style="color: #008000;">/*</span><span style="color: #008000;">旋转 图片</span>*/
然后是点击关闭按钮,广告向下消失,侧边出现效果
<span style="color: #008080;">1</span> <span style="color: #800000;">#fimg-min</span>{ <span style="color: #008080;">2</span> <span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 80px</span>; <span style="color: #008080;">3</span> <span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;"> 140px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图片大小 </span><span style="color: #008000;">*/</span> <span style="color: #008080;">4</span> <span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> fixed</span>; <span style="color: #008080;">5</span> <span style="color: #ff0000;"> bottom</span>:<span style="color: #0000ff;"> 0px</span>; <span style="color: #008080;">6</span> <span style="color: #ff0000;"> left</span>:<span style="color: #0000ff;"> 0px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">定位</span><span style="color: #008000;">*/</span> <span style="color: #008080;">7</span> <span style="color: #ff0000;"> display</span>:<span style="color: #0000ff;"> none</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">隐藏</span><span style="color: #008000;">*/</span> <span style="color: #008080;">8</span> <span style="color: #ff0000;"> cursor</span>:<span style="color: #0000ff;"> pointer</span>; <span style="color: #008000;">/*</span><span style="color: #008000;">小手 </span><span style="color: #008000;">*/</span> <span style="color: #008080;">9</span> }
点击图中圈出来的图标,底部广告再次出现
<span style="color: #008080;"> 1</span> <script> <span style="color: #008080;"> 2 $(document).ready(<span style="color: #0000ff;">function<span style="color: #000000;">(){ <span style="color: #008080;"> 3 $(".close").click(<span style="color: #0000ff;">function<span style="color: #000000;"> () { <span style="color: #008080;"> 4 $('.footfixed'<span style="color: #000000;">).animate( <span style="color: #008080;"> 5 {height: '10px', opacity: '0.4'}, "slow", <span style="color: #0000ff;">function<span style="color: #000000;"> () { <span style="color: #008080;"> 6 $('.footfixed'<span style="color: #000000;">).hide(); <span style="color: #008080;"> 7 $('#fimg-min'<span style="color: #000000;">).show(); <span style="color: #008080;"> 8 <span style="color: #000000;"> }); <span style="color: #008080;"> 9 <span style="color: #000000;"> }); <span style="color: #008080;">10 $('#fimg-min').click(<span style="color: #0000ff;">function<span style="color: #000000;">(){ <span style="color: #008080;">11 $('.footfixed').show().css({height:'140px',opacity:'1'<span style="color: #000000;">}); <span style="color: #008080;">12 $('#fimg-min'<span style="color: #000000;">).hide(); <span style="color: #008080;">13 <span style="color: #000000;"> }); <span style="color: #008080;">14 <span style="color: #000000;">}); <span style="color: #008080;">15 </script> <span style="color: #008080;">16</span>
注:在ie9以下浏览器中关闭按钮图片旋转效果未能实现。
注意:本文为原创,转载请以链接形式标明本文地址 ,谢谢合作。
本文地址:http://www.cnblogs.com/wanghuih/p/5546441.html

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.

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.

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

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.

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

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.

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.

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.


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function