web开发笔记-css常用属性(1)

2016-12-26  本文已影响31人  小貔

简介

这次主要介绍一些css常用属性

内容

1. 颜色属性:
** color**

-css: .colorHEX {
            color: #B0F566;
        }
        
        .colorRGB {
            color: RGB(74, 242, 161);
        }
        
        .colorRGBA {
            color: RGBA(74, 242, 161, .5);
        }
        
        .colorHSL {
            color: HSL(200, 86%, 63%);
        }
        
        .colorHSLA {
            color: hsla(200, 86%, 63%, .5);
        }
-html:
<div class="colorHEX">color: #B0F566</div>
<div class="colorRGB"> color: RGB(74, 242, 161)</div>
<div class="colorRGBA"> color: RGBA(74, 242, 161, .5) </div>
<div class="colorHSL">color: HSL(200, 86%, 63%);</div>
<div class="colorHSLA"> color:HSLA(200, 86%, 63%, .5)</div>
color.png

2. 字体属性:
** font-style: 用于规定斜体文本**

-css:
   .normal {
            font-style: normal;
        }
        
        .italic {
            font-style: italic;
            color: HSL(200, 86%, 63%);
        }
        
        .oblique {
            font-style: oblique;
            color: RGB(74, 242, 161);
        }
-html:
        <div class="normal"> font-style: normal</div>
        <div class="italic"> font-style: italic</div>
        <div class="oblique"> font-style: oblique</div>
font-style.png

font-weight: 设置文本的粗细

-css:
 .bold {
            font-weight: bold;
            color: HSL(200, 86%, 63%);
        }
        
        .bolder {
            font-weight: bolder;
            color: HSL(200, 86%, 63%);
        }
        
        .lighter {
            font-weight: lighter;
            color: HSL(200, 86%, 63%);
        }
        
        ._100 {
            font-weight: 100;
            color: HSL(200, 86%, 63%);
        }
        
        ._600 {
            font-weight: 600;
            color: HSL(200, 86%, 63%);
        }
-html:
 <div class="">font-weight:normal</div>
 <div class="bold">font-weight:bold</div>
 <div class="bolder">font-weight:bolder</div>
 <div class="lighter">font-weight:lighter</div>
<div class="_600">font-weight:600</div>
 <div class="_100">font-weight:100</div>
font-weight.png

font-size: 设置字体的大小

-css:
 .xx-small {
            font-size: xx-small;
        }
        
        .xx-large {
            font-size: xx-large;
        }
        
        ._200 {
            font-size: 200%;
        }
        
        .length_30px {
            font-size: 20px;
        }
-html:
    <div class="">font-size: medium</div>
    <div class="xx-large">font-size: xx-large</div>
    <div class="xx-small">font-size: xx-small</div>
    <div class="_200">font-size: 200%</div>
    <div class="length_30px">font-size: 20px</div>
font-size.png

3. 文本属性:
white-space: 设置元素中空白的处理方式

-css:
 .pre {
            white-space: pre;
        }
        
        .nowrap {
            white-space: nowrap;
        }
        
        .pre-wrap {
            white-space: pre-wrap;
        }
        
        .pre-line {
            white-space: pre-line;
        }
     -html:
    <div class="box  "> white-space: normal; 任何值得做的,就把它做好。</div>
    <div class="box pre"> white-space: pre; 任何值得做的,就把它做好。</div>
    <div class="box nowrap"> white-space: nowrap;任何值得做的,就把它做好。</div>
    <div class="box pre-wrap"> white-space: pre-wrap; 任何值得做的,就 把 它 做 好。</div>
    <div class="box pre-line"> white-space: pre-line; 任何值得做的, 就 把 它 做 好。</div>
white-space.png

text-align: **文本的水平对齐方式 **

 -css:
       .text-left {
            text-align: left
        }
        .text-center {
            text-align: center
        }
        .text-right {
            text-align: right
        }
-html:
    <div class="box text-left">text-left</div>
    <div class="box text-center">text-center</div>
    <div class="box text-right">text-right</div>
text-align.png

vertical-align: **文本的垂直对齐方式 **
可详见web开发笔记之vertical-align

结束

上一篇 下一篇

猜你喜欢

热点阅读