Heim  >  Artikel  >  Web-Frontend  >  CSS样式之背景、文本

CSS样式之背景、文本

WBOY
WBOYOriginal
2016-06-08 08:47:521022Durchsuche

一、背景

    1、背景颜色用background-color属性,例如:body{background-color:red}
    2、用图像做背景用background-image属性,例如body{background-image:ul1(23.jpg)
    3、背景由图片重复平铺用backgroud-repeat属性,repeat-x或repeat-y分别表示水平或垂直平铺,
         no-repeat表示允许从任何方向上平铺
         例如:body
                 {background-image:url(23.jpg)
                  background-repeat:repeat-x:) } 
    4、用background-position属性将背景定位,[位置:top、bottom、left、right、center、还可使用 
         百分比(50% 50%)、长度值(50px 50px)]
         例如:body
                 {background-image:url(23.jpg)
                  background-position:center}
     5、设置图片关联属性用background-attachment,例如下面的图片背景不会随文字的滚动而滚动
                   body{background-image:url(23.jpg);
                                   background-repeat:no-repeat;
                                   background-attachment:fixed;}
二、文本
     1、缩进文本用text-indent属性,最常见的是段落首行缩进,缩进值可以还负数
          例如:p{text-indent:-5em},但设置负数容易超出浏览器窗口左边界,要特别注意;
          缩进值单位可以是百分数%,长度单位px,度量单位em;
          text-indent属性可以继承,例如:
         div#outer {width:500px;}
         div#inter  {text-indent:10%}
         p{width:200px;}
               
               
some text.some text.some text.
                         

this is a pragramph

               
               
    2、水平对齐用text-align属性(left、right、center、justity)
    3、word-spacing可以改变字(单词)之间的标准间隔,默认值normal与设置值为0是一样的,    
         word-spacing接受正长度值也可接受负长度值
    4、letter-spacing改变字符和字母之间的间距,其他同word-spacing,默认值normal与设置值为0是          
           一样的,接受正长度值和负长度值
    5、text-transform处理文本的大小写(none、uppercase大写、lowercase小写、capitalize首字母为大
         写
    6、text-decoration处理文本装饰(none、underline、overline上划线、line-through贯穿线、blink闪    
        烁
    7、处理空白符white-space    
          值pre-line,空白符:合并,换行符:保留,自动换行:允许;
          值normal,空白符:合并,换行符:忽略,自动换行:允许;
          值nowrap,空白符:合并,换行符:保留,自动换行:不允许
          值pre-wrap,空白符:保留,换行符:保留,自动换行:允许
    8、direction属性影响块级元素中文本的书写方向,列表中布局的方向、内容水平填充其文本框的方向以    
         及两端对齐元素中最后一行的位置(值有两个,ltr和rtk,其中ltr为默认值,为从左到右的方向)
    9、line-height设置行高
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn