没有样式就是最好的样式

Archive for January, 2005


关于页面重定向的问题

Jan 27, 2005 Author: | Filed under: Uncategorized

刚看到 Use standard redirects 这篇文章,简单地说,就是不要使用 meta refresh 方法来转向,而因该是用服务器端的请求转发。

以下为引用内容:

Redirecting Requests to a Directory

You can redirect requests for files in one directory to a different directory, to a different Web site, or to another file in a different directory. When the browser requests the file at the original URL, the Web server instructs the browser to request the page by using the new URL.

To redirect requests to another directory or Web site

1. In the Internet Information Services snap-in, select the Web site or directory and open its property sheets.

2. Click the Home Directory, Virtual Directory, or Directory tab.

3. Select A Redirection to a URL.

4. In the Redirect To box, type the URL of the destination directory or Web site. For example, to redirect all requests for files in the /Catalog directory to the /NewCatalog directory, type /NewCatalog.

To redirect all requests to a single file

1. In the Internet Information Services snap-in, select the Web site or directory and open its property sheets.

2. Click the Home Directory, Virtual Directory, or Directory tab.

3. Select A Redirection to a URL.

4. In the Redirect To box, type the URL of the destination file.

5. Select The Exact URL Entered Above to prevent the Web server from appending the original file name to the destination URL.


原文在:

microsoft IIS 设置说明

[Edit on 2005-1-27 11:33:58 By guoshuang]

网页标准好文推荐

Jan 27, 2005 Author: | Filed under: Uncategorized

http://neoone.51.net/ 看到不少好东东,原文(english)都在 W3C,可是W3C的东西太多了,一会就迷失了….:(

原文:

Quality Tips for Webmasters

中文翻译

更多知识:

http://www.w3.org/Provider/Style/

发现 firefox - view page source 的 HTML validator 很不错,报告了很多错误,改了几个,一点一点来吧。

[Edit on 2005-1-27 11:17:03 By guoshuang]
[Edit on 2005-1-27 13:28:59 By guoshuang]

全角转半角的代码

Jan 26, 2005 Author: | Filed under: Uncategorized

我佛山人这个家伙写的代码,这家伙…

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

山人原代码:

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

VBS的,只能转单个字符

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

[Edit on 2005-1-26 17:07:53 By guoshuang]

下载而不是打开 .swf 文件的代码

Jan 26, 2005 Author: | Filed under: Uncategorized

在 !blueidea 看到 panliu888 的回复。

http://www.blueidea.com/bbs/newsdetail.asp?id=1885777&posts=

显示更多

nofollow 到底怎么用?

Jan 26, 2005 Author: | Filed under: Uncategorized

今天突然在 donews 看到这样的代码,不是很理解。已经都没有 href 信息了,干嘛还 nofollow,而且留言仍然需要填写 url,这下可好,别说 bot 连读者都没法互相交流主页了。后面还留着 target….萝卜快了,不洗泥?

显示更多

另外,keso 那里看到有个反对的说法,nofollow 连优秀 comments 的宣传权利都剥夺了,而keso 的回答语焉不详。我想这有点象软件商和盗版用户之间的关系。类似 keso 这样大流量的站点肯定不喜欢被别人不友好地利用。但是,这样的spam comment 骗取 pr 或者 眼球 的行为难道比大家都心安理得的用着盗版软件还要糟糕吗?

[Edit on 2005-1-26 14:41:02 By guoshuang]

css 技巧(Ten CSS tricks you may not know)

Jan 20, 2005 Author: | Filed under: Uncategorized

在 del.icio.us 的 popular 看到的,基本上都看过了,再复习一下…原文在:

http://www.evolt.org/article/Ten_CSS_tricks_you_may_not_know/17/60369/

1. CSS font shorthand rule

When styling fonts with CSS you may be doing this:

font-size: 1em;

line-height: 1.5em;

font-weight: bold;

font-style: italic;

font-variant: small-caps;

font-family: verdana,serif;

There’s no need though as you can use this CSS shorthand property:

font: 1em/1.5em bold italic small-caps verdana,serif

Much better! Just a couple of words of warning: This CSS shorthand version will only work if you’re specifying both the font-size and the font-family. Also, if you don’t specify the font-weight, font-style, or font-varient then these values will automatically default to a value of normal, so do bear this in mind too.

2. Two classes together

Usually attributes are assigned just one class, but this doesn’t mean that that’s all you’re allowed. In reality, you can assign as many classes as you like! For example:

Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both text and side. If any rules overlap between the two classes then the class which is below the other in the CSS document will take precedence.

3. CSS border default value

When writing a border rule you’ll usually specify the colour, width and style (in any order). For example, border: 3px solid #000 will give you a black solid border, 3px thick. However the only required value here is the border style.

If you were to write just border: solid then the defaults for that border will be used. But what defaults? Well, the default width for a border is medium (equivalent to about 3 to 4px) and the default colour is that of the text colour within that border. If either of these are what you want for the border then you can leave them out of the CSS rule!

4. !important ignored by IE

Normally in CSS whichever rule is specified last takes precedence. However if you use !important after a command then this CSS command will take precedence regardless of what appears after it. This is true for all browsers except IE. An example of this would be:

margin-top: 3.5em !important; margin-top: 2em

So, the top margin will be set to 3.5em for all browsers except IE, which will have a top margin of 2em. This can sometimes come in useful, especially when using relative margins (such as in this example) as these can display slightly differently between IE and other browsers.

(Many of you may also be aware of the CSS child selector, the contents of which IE ignores.)

5. Image replacement technique

It’s always advisable to use regular HTML markup to display text, as opposed to an image. Doing so allows for a faster download speed and has accessibility benefits. However, if you’ve absolutely got your heart set on using a certain font and your site visitors are unlikely to have that font on their computers, then really you’ve got no choice but to use an image.

Say for example, you wanted the top heading of each page to be ‘Buy widgets’, as you’re a widget seller and you’d like to be found for this phrase in the search engines. You’re pretty set on it being an obscure font so you need to use an image:

Buy widgets

This is OK but there’s strong evidence to suggest that search engines don’t assign as much importance to alt text as they do real text (because so many webmasters use the alt text to cram in keywords). So, an alternative would be:

Buy widgets

Now, this obviously won’t use your obscure font. To fix this problem place these commands in your CSS document:

h1

{

background: url(widget-image.gif) no-repeat;

}

h1 span

{

position: absolute;

left:-2000px;

}

The image, with your fancy font, will now display and the regular text will be safely out of the way, positioned 2000px to the left of the screen thanks to our CSS rule.

6. CSS box model hack alternative

The box model hack is used to fix a rendering problem in pre-IE 6 browsers, where by the border and padding are included in the width of an element, as opposed to added on. For example, when specifying the dimensions of a container you might use the following CSS rule:

#box

{

width: 100px;

border: 5px;

padding: 20px;

}

This CSS rule would be applied to:

This means that the total width of the box is 150px (100px width + two 5px borders + two 20px paddings) in all browsers except pre-IE 6 versions. In these browsers the total width would be just 100px, with the padding and border widths being incorporated into this width. The box model hack can be used to fix this, but this can get really messy.

A simple alternative is to use this CSS:

#box

{

width: 150px;

}

#box div {

border: 5px;

padding: 20px;

}

And the new HTML would be:

Perfect! Now the box width will always be 150px, regardless of the browser!

7. Centre aligning a block element

Say you wanted to have a fixed width layout website, and the content floated in the middle of the screen. You can use the following CSS command:

#content

{

width: 700px;

margin: 0 auto;

}

You would then enclose

around every item in the body of the HTML document and it’ll be given an automatic margin on both its left and right, ensuring that it’s always placed in the centre of the screen. Simple… well not quite - we’ve still got the pre-IE 6 versions to worry about, as these browsers won’t centre align the element with this CSS command. You’ll have to change the CSS rules:

body

{

text-align: center;

}

#content

{

text-align: left;

width: 700px;

margin: 0 auto;

}

This will then centre align the main content, but it’ll also centre align the text! To offset the second, probably undesired, effect we inserted text-align: left into the content div.

8. Vertically aligning with CSS

Vertically aligning with tables was a doddle. To make cell content line up in the middle of a cell you would use vertical-align: middle. This doesn’t really work with a CSS layout. Say you have a navigation menu item whose height is assigned 2em and you insert this vertical align command into the CSS rule. It basically won’t make a difference and the text will be pushed to the top of the box.

Hmmm… not the desired effect. The solution? Specify the line height to be the same as the height of the box itself in the CSS. In this instance, the box is 2em high, so we would insert line-height: 2em into the CSS rule and the text now floats in the middle of the box - perfect!

9. CSS positioning within a container

One of the best things about CSS is that you can position an object absolutely anywhere you want in the document. It’s also possible (and often desirable) to position objects within a container. It’s simple to do too. Simply assign the following CSS rule to the container:

#container

{

position: relative;

}

Now any element within this container will be positioned relative to it. Say you had this HTML structure:

To position the navigation exactly 30px from the left and 5px from the top of the container box, you could use these CSS commands:

#navigation

{

position: absolute;

left: 30px;

top: 5px;

}

Perfect! In this particular example, you could of course also use margin: 5px 0 0 30px, but there are some cases where it’s preferable to use positioning.

10. Background colour running to the screen bottom

One of the disadvantages of CSS is its inability to be controlled vertically, causing one particular problem which a table layout doesn’t suffer from. Say you have a column running down the left side of the page, which contains site navigation. The page has a white background, but you want this left column to have a blue background. Simple, you assign it the appropriate CSS rule:

#navigation

{

background: blue;

width: 150px;

}

Just one problem though: Because the navigation items don’t continue all the way to the bottom of the screen, neither does the background colour. The blue background colour is being cut off half way down the page, ruining your great design. What can you do!?

Unfortunately the only solution to this is to cheat, and assign the body a background image of exactly the same colour and width as the left column. You would use this CSS command:

body

{

background: url(blue-image.gif) 0 0 repeat-y;

}

This image that you place in the background should be exactly 150px wide and the same blue colour as the background of the left column. The disadvantage of using this method is that you can’t express the left column in terms of em, as if the user resizes text and the column expands, it’s background colour won’t.

At the time of writing though, this is the only solution to this particular problem so the left column will have to be expressed in px if you want it to have a different background colour to the rest of the page.