CSS: Set border to half width

前端 未结 7 883
说谎
说谎 2021-02-12 21:57

Consider following:

...
.box{ width:500px; border-bottom: 1px solid #ccc; }

It will set the bot

7条回答
  •  隐瞒了意图╮
    2021-02-12 22:36

    You can Use ::after or ::before pseudo-selectors. Like:

    something here

    CSS:

    div {
        width: 500px;
        height: 100px;
        position: relative;
        padding-top: 20px;
        margin-top: 50px;
    }
    
    div::before {
        content: '';
        display: block;
        position: absolute;
        top: 0;
        width: 50%;
        left: 25%;
        border-top: 1px solid red;
    }
    

    Here is the jsfiddle

提交回复
热议问题