首页
网页制作
网络编程
脚本专栏
数据库
网站运营
网络安全
平面设计
CMS教程
搜索
建站极客
网页制作
CSS
正文
广告始终定位到网页右下角 css
所属分类:
网页制作
/
CSS
阅读数: 378
收藏 0
赞 0
分享
互联网提供了很多种“将广告始终定位到网页右下角”的解决方案,大多会用到javascript,其实仅调用样式表就可以实现该效果。
以下万恶的代码主要是写给IE6的,在IE7和FF浏览器中,只需要position:fixed就可以将图层定义到网页的任意位置。
CSS Code
复制内容到剪贴板
body{
margin
:0;
border
:0;
height
:100%;
overflow
-y:
auto
;}
#test
{
display
:
block
;
bottom
bottom
:
3px
;
right
right
:
3px
;
width
:
130px
;
position
:
fixed
;}
/* 以下是写给IE6的 */
* html
#test
{
position
:
absolute
;
right
right
:
18px
}
* html{
overflow
-x:
auto
;
overflow
-y:
hidden
;}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> body{margin:0;border:0; height:100%;overflow-y:auto;} #test {display:block; bottom:3px; right:3px; position:fixed;} * html #test {position:absolute; right:18px} * html{overflow-x:auto; overflow-y:hidden;} </style> <title>Fixed layer in MSIE.position:fixed;</title></head> <body> <div> <div> <h1> Fixed layer in MSIE</h1> <p> This is a simulation of CSS "position: fixed" for MSIE. The main text on this page is contained in a 100% high, scrollable <div>. The scrollbar belongs to the <div>, not to the <body>. The ordinary <body> content is found in the fixed green box. All HTML and CSS on this page should follow the W3C spec except overflow-y: hidden, which is used for cosmetical purposes in earlier IE versions. </p> <h2> Browser support </h2> <p>The browsers listed below are those I have tested in so far. I don't know how other browsers will behave. Because of the <strong>problems in Opera 7.10</strong> I recommend using Conditional Comments (section 3, example A), which hides CSS from all browsers except MSIE 5+. Other browsers like Mozilla and Opera may use CSS position: fixed instead (that's how I've done it on this page).</p> <p> Note that if you hide parts of the CSS from non-MSIE browsers (like on this page) the details about non-MSIE browsers below do not apply. </p> <h3>Supporting browsers</h3> <ul> <li>MSIE 4.72/win</li> <li>MSIE 5.0/win</li> <li>MSIE 6.0</li> <li>Netscape 6.1+</li> <li>Mozilla</li> <li>Opera 7.0</li> <li>Opera 7.11 (<strong>not 7.10</strong>)</li> </ul> <h3>Non-supporting browsers</h3> <ul> <li>Netscape 4.x (degrades gracefully)</li> <li>MSIE 4/mac</li> <li>MSIE 5/mac (not sure about the details)</li> <li>Opera 6.0 (degrades gracefully)</li> <li><strong>Opera 7.10 (freezes)</strong></li> </ul> <h3>General problems</h3> <ul> <li>In IE5 and IE6/quirk mode double scrollbars will appear unless one adds the non-standard CSS overflow-y: hidden property.</li> <li>Content must be contained in either the scrollable or the fixed <div>, not outside any of them.</li> <li>If you apply margin or padding to div#fixedcontent, Mozilla adds this to the 100% height and width which results in double scrollbars. Because of that I have nested a div#innerbox and apply the padding to that instead. This does not seem necessary for MSIE 6.</li> <li>The scrolling content must be absolutely positioned for Opera 7.</li> <li>The fixed content can obscure other content, and can itself easily become obscured in small browser windows.</li> </ul> <p> </p> <h2>'position:fixed' in IE</h2> <p>Since the project I was working on for Q42 together with Sjoerd had to wait a little we thought it would be a good idea to update the site of their <abbr>WYSIWYG</abbr> <abbr>XML</abbr> Editor, Xopus. There are still a few minor mistakes on the site (validating and all that), but those do not make the site inaccessible or so. We also could not use <abbr>UTF-8</abbr> (learn about <abbr>UTF-8</abbr>, leer over <abbr>UTF-8</abbr>) because the current httpd.conf file did not allow specifying a .htaccess and modyfying the server configuration file was not considered to be a good idea (and nobody who was around was sure if we were just allowed to read it, or if we could overwrite as well) just before the weekend. I guess those things will be fixed eventually. (Obviously, the same is true for putting mod_negotation to work.) </p> <p>Anyway, the cool thing of the original site was the fixed top and bottom. It was done with some scripting that did not work cross browser. In Mozilla you could not scroll and in Safari the content was not shown. Although Xopus is a product just for Internet Explorer thanks to not supporting of (for example) contentEditable="true" in others the website could at least be made accessible so people using other browser then Internet Explorer could check what the product is about. </p> <p>However, emulating position:fixed was rather tricky. I first thought of using some fixed positioning technique I developed ages ago, but did not quite emulate the intented effect. (In Internet Explorer it looks like you are using frames, which is not what we wanted.) There are some examples on the internet but most made the fixed element "flicker". You can see that here. Of course, you want better; position:fixed in IE. Although there are workarounds for Internet Explorer 6.0 in standards mode, just use quirks. It is so much easier, especially if you have to cope with Internet Explorer 5.5 (and even 5.0) as well. </p> <p>The difference between the two files is background:url(foo) fixed. Although the existence of the file foo is not really needed, make sure 'foo' is some zero byte file to prevent stupid 404 requests. You might think the reference to foo is not needed at all and you can just write background-attachment:fixed. Unfortunately, that is incorrect. Internet Explorer probably runs a bit different when this setting is set. </p> <p>All other things are pretty clear, I hope. Have fun. </p> <p> </p> </div> </div> <div id="test"> <img src="https://www.jb51.net/images/logo.gif" /> </div> </body> </html>
提示:可以修改后运行.
必要元素:
DOCTYPE声明 、 html标签 、body标签 、 一个ID为test的div。
更多精彩内容
其他人还在看
CSS配合JavaScript做酷的动态页面效果
利用CSS配合JavaScript的可以做很多更酷的动态页面效果,在本教程的最后给大家简单介绍一下CSS配合JS的应用。首先,要搞清楚事件和动作的概念。在客户端脚本中,JavaScript 通过对事件进行响应来获得与用户的交互。例如,当用户单击一个按钮或者在某段文字上移动鼠标
评论 0
收藏 0
赞 0
分享
WEB标准,Web前端开发工程师必备技术列表
想要打造并拥有一流的Web产品开发团队,在团队成员基础能力上一定要下功夫。对于Web前端产品开发来说,仅仅掌握Web1.0时代简单的"网页套接"是完全不够的。我结合自己的团队配备,特此罗列了Web前端产品工程师所涉及的技能列表如下: 通过许多实际项目,
评论 0
收藏 0
赞 0
分享
用CSS制作Alpha滤镜测试板
alpha滤镜给制作网页特效提供了较大的创作空间,但由于它控制参数较多,在实际应用时,为了确定一组合适的参数值,不得不反复调整修改,在编辑窗口和预览窗口来回倒腾,甚是麻烦,本文介绍了一种简单的方法。制作一个“Alpha滤镜参数测试板”,在测试板上输入参数
评论 0
收藏 0
赞 0
分享
非常流行的所谓的气泡窗口
普通的Alt无法自定义风格,而Sweet Titles通过JS脚本与CSS的集合.自定义了这种伪Alt风格. 前一段时间非常流行的,就所谓的气泡窗口(鼠标移到链接处出现的). 我们这里实现的用的是Sweet Titles的插件.显示效果完全由CSS控制.. 先下载Sweet Ti
评论 0
收藏 0
赞 0
分享
CSS教程:li和ul标签用法举例
LI代码的格式化: A).运用CSS格式化列表符: ul li{ list-style-type:none; } B).如果你想将列表符换成图像,则: ul li{ list-style-type:none; list-style-image: url(/blog/images/
评论 0
收藏 0
赞 0
分享
CSS教程:CSS中的定位(position)
使用CSS来定位页面内层的位置,一直是比较难以掌握的事情,很多时候,往往被绝对定位的元素,总是以浏览器的左上角为坐标原点,此时,如果浏览器的大小改变,被定义的层就会偏离设计想要的位置,让人很挠头。 其实,要想控制好层的绝对定位,只要理解CSS中关于定位
评论 0
收藏 0
赞 0
分享
CSS教程:盒模型(BOX Model)
如果想熟练掌握DIV和CSS的布局方法,首先要对盒模型有足够的了解。每个HTML元素都可以看作一个装了东西的盒子,盒子里面的内容到盒子的边框之间的距离即填充(padding),盒子本身有边框(border),而盒子边框外和其他盒子之间,还有边界(margin),如图1所示。
评论 0
收藏 0
赞 0
分享
无延迟翻滚的图形与CSS混合风格按钮
在一个具有图形背景的按钮中添加CSS风格的文本,这种建立按钮的方法结合了具有CSS翻滚(CSS rollover)标记的开发速度和效率,从而有效地提高按钮外表图像的三维效果。 相比于常规的图形按钮,这些图形/CSS混合按钮可易于建立和载入,因为你只需要为空白按钮外面
评论 0
收藏 0
赞 0
分享
css里expression实现界面对象的批量控制
用过css样式我们就知道, 可以定义一批对象的class属性来指定同一个样式来统一界面. 但如何统一同类型的对象的事件? 比如:界面有无数个 <img src="**.jpg"> 如何实现鼠标经过此图片, 图片的src变成是**_over.jpg?
评论 0
收藏 0
赞 0
分享
CSS教程:水平对齐(text-align)
水平对齐(text-align),用以设定元素内文本的水平对齐方式。 1.语法 text-align具体参数如下: 语法:text-align:left|right|center|justify 说明:设定元素内文本的水平对齐方式。 参数:left:左
评论 0
收藏 0
赞 0
分享
查看更多
网络赚钱
更多
内容型网站实现盈利的6种方法
男子凭一张八卦图忽悠60多亲友发红包 短短1小时内获得300元红包
打工妹网购6000多元丰胸产品 无效要求退款时又被骗10万元
网上怎么赚钱 网络赚钱需要注意哪些东西
Google
新手站长谈谈如何做好广告联盟
站长故事
更多
被低估的公司(一):写在阿里IPO之后
奇幻咔咔3D小熊孟得明 揭秘瞬间火爆网络的背后故事
揭秘互联网骗子怎么做到月入过万
站长们,就别在折腾你的用户了
八零后站长们:我们都是“囧”的一代
浅谈新手站长在网站运营中如何去养站?