且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在线CSS有什么坏?

更新时间:2023-02-05 21:40:56

使网站看起来不同。这可能不适用于您的示例,但如果您对

Having to change 100 lines of code when you want to make the site look different. That may not apply in your example, but if you're using inline css for things like

<div style ="font-size:larger; text-align:center; font-weight:bold">

在每页上表示一个页眉,这将更容易维护为

on each page to denote a page header, it would be a lot easier to maintain as

<div class="pageheader">  

如果页眉在一个样式表中定义,那么如果你想改变页眉的样式整个网站,你改变css在一个地方。

if the pageheader is defined in a single stylesheet so that if you want to change how a page header looks across the entire site, you change the css in one place.

但是,我会是一个异端,并说,在你的例子,我没有看到问题。你的目标是一个单一的图像的行为,这可能需要在一个单一的页面上查看,所以把实际的css在一个样式表可能是过度。

However, I'll be a heretic and say that in your example, I see no problem. You're targeting the behavior of a single image, which probably has to look right on a single page, so putting the actual css in a stylesheet would probably be overkill.