css基礎-盒子模型+背景和列表

border-style的值:css

none 無html

dotted 點狀前端

dashed 虛線ide

solid 實線url

double 雙實線spa

 


 

margin:3d

垂直方向兩個相鄰元素都設置了外邊距,那麼外邊距會發生合併code

合併高度=兩個發生合併的外邊距中的較大值htm

 


 

元素的實際高度=上邊框+上內邊距+內容高度+下內邊距+下邊框blog

元素在頁面中實際所佔的高度是:上外邊距+上邊框+上內邊距+內容高度+下內邊距+下邊框+下外邊距

 


 

hover屬性實現鼠標懸停時顯示子元素:

<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>display屬性</title>
    <style type="text/css">
    div {
        width: 200px;
    }
    /*補充樣式*/
    ul{
        margin-left:-36px;
    }
    li{
        display: none;
    }
    div:hover li{
        display: inline-block;
        list-style: none;
    }
    </style>
</head>

<body>
    <div>
        <h2>家電</h2>
        <ul>
            <li>冰箱</li>
            <li>空調</li>
            <li>洗衣機</li>
        </ul>
    </div>
</body>

</html>

inline將元素顯示爲內聯元素,元素先後沒有換行符

行內元素沒法設置寬和高,外邊距只能設置左右的,沒法設置上下的

 


 

列表demo:

<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>display屬性</title>
    <style type="text/css">
    *{margin:0;padding:0;}
    .wrap {
        width: 220px;
        background-color:#f2f4f6;
        border:1px solid #ececec;
        margin:0 auto;
    }
    .list{
        width:100%;
        height:150px;
        background-color:#040a10;
        text-align:center;
        color:#fff;
        line-height:150px;
        font-size:20px;
        font-weight:bold;
    }
    li{
        list-style: none;
        border-bottom:1px solid #d9dde1;
        font-size:14px;
        line-height:1.5em;
        margin:0 15px;
        padding:10px 5px 5px 5px;
    }
    li:last-child{
        border-bottom:none;
    }
    </style>
</head>

<body>
    <div class="wrap">
        <div class="list">
            <p>前端課程排列</p>
        </div>
        <ul>
            <li>
                <p>HTML+CSS基礎課程</p>
                <span>456605人在學</span>
            </li>
            <li>
                <p>HTML+CSS基礎課程</p>
                <span>456605人在學</span>
            </li>
            <li>
                <p>HTML+CSS基礎課程</p>
                <span>456605人在學</span>
            </li>
        </ul>
    </div>
</body>

</html>

 

 

 

鼠標懸停顯示demo:

<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="UTF-8">
        <title>display屬性</title>
        <style type="text/css">
          *{margin:0;padding:0;}
          .big{width: 150px;margin: 10px auto 0 auto;background: #f2f4f6;border: 1px solid #ddd;}
          h3{height: 40px;line-height: 40px;text-align: center;}
          .div1 h3{border-bottom: 1px solid #ddd;}
          .div2 h3{border-bottom: 1px solid #ddd;}
          ul{background-color:#fff;display: none;}
          ul li{ height: 30px;line-height: 30px;margin-left: 58px;list-style: none;}
          .div1:hover .elec{display: block;border-bottom: 1px solid #ddd;}
          .div2:hover .wash{display: block;border-bottom: 1px solid #ddd;}
          .div3:hover .clothes{display: block;border-top: 1px solid #ddd;}
        </style>
    </head>
    <body>
    <div class="big">
        <div class="div1">
            <h3>家電</h3>
            <ul class="elec">
                <li>冰箱</li>
                <li>洗衣機</li>
                <li>空調</li>
            </ul>
        </div>
        <div class="div2">
            <h3>洗護</h3>
            <ul class="wash">
                <li>洗衣液</li>
                <li>消毒液</li>
                <li>柔順劑</li>
            </ul>
        </div>
        <div  class="div3">
            <h3>衣物</h3>
             <ul class="clothes">
                <li>襯衫</li>
                <li>褲子</li>
                <li>衛衣</li>
            </ul>
        </div>
      </div>
</body>
</html>

 

 

 

background-color:transparent 透明,是默認值

背景區包括內容+內邊距+邊框,不包括外邊距

background-repeat:repeat、no-repeat、repeat-x、repeat-y、inherit

background-attachment:scroll(默認)/ fixed

background-position:

值(x y)(x% y%)(只有一個參數表明第二個默認居中)/top/bottom/left/right/center(水平垂直居中)

 

 

background簡寫:後面的屬性值不分順序

 


 

有序列表樣式:

 

 

list-style-position:inside(嵌入文本中)/outside(在全部文本左側)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <style>
     li{
         list-style-image:url(http://climg.mukewang.com/58dc9e4e0001ba9000160016.png);
     }
    </style>
</head>
<body>
    <ul>
        <li>電視</li>
        <li>冰箱</li>
        <li>洗衣機</li>
        <li>空調</li>
    </ul>
</body>

 

 

相關文章
相關標籤/搜索