日期:2014-05-17  浏览次数:20869 次

有必要在body,table,input都声明字体么?
今天看了一个小站的css文件,里面这样的.
那么有必要body,table,input,textarea都声明字体么?直接在第一个body声明不就是了么?
++++
BODY   {
FONT-SIZE:   12px;   BACKGROUND:   url(/images/bg.gif?06042100)   #1cb6fe   no-repeat   center   top
}
  {
FONT-SIZE:   1em
}
BODY   {
FONT-FAMILY:   arial,sans-serif
}
这两个合并起来会不会更好?
++++++++

BODY   {
FONT-SIZE:   12px;   BACKGROUND:   url(/images/bg.gif?06042100)   #1cb6fe   no-repeat   center   top
}
  {
FONT-SIZE:   1em
}
BODY   {
FONT-FAMILY:   arial,sans-serif
}
TABLE   {
FONT-FAMILY:   arial,sans-serif
}
INPUT   {
FONT-FAMILY:   arial,sans-serif
}
TEXTAREA   {
FONT-FAMILY:   arial,sans-serif
}
SELECT   {
FONT-FAMILY:   arial,sans-serif
}
#wrap   {
MARGIN:   0px   auto;   WIDTH:   760px
}

------解决方案--------------------
可以在CSS文件里面定义一个类,在每个里面只用引用
A.a3:active {
color: #000000;
text-decoration: none;
font-size: 12px;
font-weight: normal;
}
<... calss= "a ">
------解决方案--------------------
相同的在body中定义即可,
如果需要定义个性化的字体可以分别定义。
------解决方案--------------------
css具有很好的继承性,因此定义
body{
font-family:arial,sans-serif;
}
里面所有的字体继承body的字体,
input里面继承的因该是arial,sans-serif;
具体请参考http://zh.html.net/tutorials/css/lesson4.asp#s1