CSS: Set border to half width

.box {
    padding-bottom: 10px;
    background-image: linear-gradient(#ccc,#ccc);
    background-size: 50% 2px;
    background-position: bottom left;
    background-repeat: no-repeat;
}

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

<div> something here </div>

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


Can you throw an <hr> at the bottom of your box?

<div class="box">
    ...
    <hr>
</div>

.box{
    width:500px;
}

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

http://jsfiddle.net/MuAKF/

Tags:

Html

Css