网页前端后台技巧(CSS+HTML) 移动 前端 Python Android Javavue那点事儿

CSS样式

2019-04-18  本文已影响1人  不爱去冒险的少年y

1.块级元素与行内元素区别

2.display

3.position

4.float

<div style="border: solid 5px #0e0; width:300px;">
        <div style="height: 100px; width: 100px; background-color: Red; float:right;">
        </div>
        <div style="height: 100px; width: 100px; background-color: Green; ">
        </div>
        <div style="height: 100px; width: 100px; background-color: Yellow;">
        </div>
    </div>
image.png
<div style="border: solid 5px #0e0; width:250px;">
        <div style="height: 120px; width: 100px; background-color: Red;  float:left;">
        </div>
        <div style="height: 100px; width: 100px; background-color: Green;  float:left;">
        </div>
        <div style="height: 100px; width: 100px; background-color: Yellow;  float:left;">
        </div>
    </div>
image.png
 <div style="border: solid 5px #0e0; width: 250px;">
        <div style="height: 50px; width: 50px; background-color: Red; float:left;"></div>
        <div style="height: 100px; width: 100px; background-color: Green;">
           11111111111
           11111111111
        </div>
    </div>
image.png
<div style="border: solid 5px #0e0; width: 250px;">
        <div style="height: 50px; width: 50px; background-color: Red; float:left;"></div>
        <div style="height: 100px; width: 100px; background-color: Green; clear:both;">
           11111111111
           11111111111
        </div>
    </div>
image.png

4. Flex

5. 居中

    .item1{ flex-grow:0; 
            background-color:green;
            line-height:50px; 
            height:50px; 
            width:50px }

image.png
   <div class='box1'>
          <div class='item2'>标签</div>
   </div>
    .box1{
        width:50px;
        height:50px;
        background-color:green;
        display: table-cell;
        vertical-align: middle;
        text-align: center;        
    }
image.png
   .span1 {
               position: absolute;
               width:100px;
               height: 50px;
               top:50%;
               left:50%;
               background:red;
               margin-left:-50px;
               margin-top:-25px;
               text-align: center;
           }
image.png
.box2{
    display: flex;
    justify-content:center;   //横向布局
    align-items:Center;   //纵向布局
}
上一篇 下一篇

猜你喜欢

热点阅读