那个加号怎么画的啊

来源:3-1 3. border-color与color

qq_刺猬先生_03549865

2016-12-29 15:40

那个加号怎么画的啊

写回答 关注

3回答

  • 光被四表
    2016-12-29 16:27:26
    已采纳

    <div class="add"></div>


    .add{

      width:100px;

      height:100px;

      border:1px solid;

      color:#ccc;

      transition:color 0.25s;

      position:relative;

    }

    .add:before{

    content:" ";

          display:block;

      width:60px;

      height:10px;

      border-color:#ccc;

      border-top:10px solid;

      position:absolute;

      top:50%;

      left:50%;

      margin: -5px 0 0 -30px ;

    }

    .add:after{

      content:" ";

      display:block;

      width:10px;

     height:60px;

      border-color:#ccc;

      border-left:10px solid;

      position:absolute;

      top:50%;

      left:50%;

      margin:-30px 0 0 -5px;

    }

    .add:hover{

      color:#f6c;

    }


    weixin...

    我觉得是空字符display成块元素这样好排版

    2019-08-08 11:32:03

    共 3 条回复 >

  • marioma
    2017-02-07 21:40:19

    <!DOCTYPE html>
    <html lang="en">
    <head>
     <meta charset="UTF-8">
     <title>Title</title>
     <style>
    .add{
         display: block;
    width:100px;
    height:100px;
    border:1px solid;
    color:#ccc;
    transition:color 0.25s;
    position:relative;
    }
       .add:before{
         content:" ";
    width:60px;
    border-top:10px solid;
    position:absolute;
    top:50%;
    left:50%;
    margin: -5px 0 0 -30px ;
    }
       .add:after{
         content:" ";
    height:60px;
    border-left:10px solid;
    position:absolute;
    top:50%;
    left:50%;
    margin:-30px 0 0 -5px;
    }
       .add:hover{
         color:#f6c;
    }
     </style>
    </head>
    <body>
    <a href="javascript:" class="add"></a>
    </body>
    </html>

  • 記憶纯白
    2016-12-29 16:32:07
    <!doctype html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
        .add{
            display: block;
            width: 100px;
            height: 100px;
            color: #ccc;
            border:1px solid;
            position: relative;
        }
        .add:before{
            content: '';
            width: 60px;
            border-top:10px solid;
            position: absolute;
            top:45px;
            left: 20px;
        }
        .add:after{
            content: '';
            height: 60px;
            border-left:10px solid;
            position: absolute;
            top:20px;
            left: 45px;
        }
        .add:hover{
            color:#06c;
        }
        </style>
    </head>
    <body>
        <a href="javascript:;"></a>
    </body>
    </html>


CSS深入理解之border

深入讲解border使用方法及应用,以及如何借助border完成布局

56800 学习 · 73 问题

查看课程

相似问题