September 30th, 2008
网页设计,让人最头疼的莫过于让页面兼容各大浏览器,准确些是兼容它们“默认”的CSS样式表。这样,“抹掉”这些默认样式表成了首要问题,也就有了CSS样式表重置一说,目前用的最多的,也是自己现在正在用的方法是,添加以下代码:
第一种方式
1
| * {margin:0px; padding:0px;} |
现在众多的设计师发现,这行代码虽然简单,但却让网页解析太慢,呵呵,当然了,自己是业余的,不用太在意。
于是出现了几种CSS重置方法:
第二种方式
NETTUTS上的 Jeffrey Way写了篇文章Weekend Quick Tip: Create Your Own Simple Reset.css File
释出自己用来重置CSS样式表的方法
1
2
3
4
5
6
7
8
9
10
11
| body, html, div, blockquote, img, label, p, h1, h2, h3, h4, h5, h6, pre, ul, ol,
li, dl, dt, dd, form, a, fieldset, input, th, td
{margin: 0; padding: 0; border: 0; outline: none;}
body{line-height: 1;font-size: 88% /* Decide for yourself if you want to include this. */;}
h1, h2, h3, h4, h5, h6{font-size: 100%;padding: .6em 0;margin: 0 15px;}
ul, ol{list-style: none;}
a{color: black;text-decoration: none;}
a:hover
{text-decoration: underline;}
.floatLeft{float: left;padding: .5em .5em .5em 0;}
.floatRight{float: right;padding: .5em 0 .5em .5em;} |
这个方法适用于大多数的网页设计。
Read the rest of this entry »
June 26th, 2008
找到一个在网页上连接并显示RSS内容的js代码,呵呵,算是可以把这个blog的发布内容,同样展示在我的org站点上。
实现方法如下:
建立一个js文件,内容为
//Container for ticker. Modify its STYLE attribute to customize style:
var tickercontainer=”
var xmlsource=”http://feed.feedsky.com/pagemod”;
var root;
var title;
var link;
var items;
var item;
var images;
var image;
var description;
if (window.ActiveXObject)
{
//document.write(“Microsoft.XMLDOM”);
var xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
}
else if (document.implementation && document.implementation.createDocument)
{
//document.write(“document.implementation.createDocument”);
var xmlDoc= document.implementation.createDocument(“”,”doc”,null);
}
if (typeof xmlDoc!=”undefined”)
{
//document.write(tickercontainer)
xmlDoc.load(xmlsource)
}
function fetchxml()
{
if (xmlDoc.readyState==4)
output()
else
setTimeout(“fetchxml()”,10)
}
function output()
{
var temp=”";
root = xmlDoc.getElementsByTagName(“channel”)[0];
title =root.getElementsByTagName(“title”)[0];
//temp = title.firstChild.nodeValue +”<br>”;
items=root.getElementsByTagName(“item”);
for(i=0;i<=items.length-1;i++)
{
item=items[i];
title=item.getElementsByTagName(“title”)[0];
link=item.getElementsByTagName(“link”)[0];
description=item.getElementsByTagName(“description”)[0];
temp = temp + “<a href=” + link.firstChild.nodeValue+ ” target=’_bank’>” + title.firstChild.nodeValue +”</a><br />”;
//temp = temp +”<font size=-1>” + description.firstChild.nodeValue + “</font><br><br>”;
document.getElementById(“rsscontainer”).innerHTML = temp;
}
}
if (window.ActiveXObject)
fetchxml()
else if (typeof xmlDoc!=”undefined”)
xmlDoc.onload=output
然后在要显示的网页html代码上连接上此文件,例子为rss.js文件。
<SCRIPT src=”rss.js” type=”text/javascript” language=”JavaScript1.2″></SCRIPT>
在你想要显示的位置,添加下面的代码:
<div id=”rsscontainer” ></div>
这样就实现了在普通网页显示某些RSS内容,自动更新网页喽。当然了,还有更多的方法,目前,在org站点,我是准备这样实现的,现在遇到的困难,是如何更改显示内容的CSS样式表,俺同样不懂js,呵呵,相当的郁闷。