How can I put a vertical line down the center of a div?

后端 未结 8 1846
陌清茗
陌清茗 2020-12-24 00:59

How do I put a vertical line down the middle of a div? Maybe I should put two divs inside the div and put a left border on one and a right border on the other? I have a DIV

8条回答
  •  囚心锁ツ
    2020-12-24 01:53

    This is my version, a gradient middle line using linear-gradient

    .block {
          width:400px;
          height:200px;
          position:relative;
     }
    .block:before {
          content:"";
          width:1px;
          height:100%;
          display:block;
          left:50%;
          position:absolute;
    	    background-image: -webkit-linear-gradient(top, #fff, #000, #fff);
          background-image: -moz-linear-gradient(top, #fff, #000, #fff);
          background-image: -ms-linear-gradient(top, #fff, #000, #fff);
          background-image: -o-linear-gradient(top, #fff, #000, #fff);
          background-image: linear-gradient(top, #fff, #000, #fff);
    	}

提交回复
热议问题