how to change length of border in css code example

Example 1: border width css

.element {
  border-width: 2px;
}

Example 2: css border length

.page-title:after {
    content: ""; /* This is necessary for the pseudo element to work. */ 
    display: block; /* This will put the pseudo element on its own line. */
    margin: 0 auto; /* This will center the border. */
    width: 50%; /* Change this to whatever width you want. */
    padding-top: 20px; /* This creates some space between the element and the border. */
    border-bottom: 1px solid black; /* This creates the border. Replace black with whatever color you want. */
}

Example 3: border width css

#some-div {
  /* [WIDTH] [FILL MODE] [COLOR] */
  border: 5px solid #f00; 
  
  /* draws solid a red line of 5px
  between the padding (inside the div)
  and the margin (outside the div) */
}

Example 4: how to set border length in css without div

div {
  width   : 200px;
  height  : 50px;   
  position: relative;
  z-index : 1;
  background: #eee;
}

div:before {
  content : "";
  position: absolute;
  left    : 0;
  bottom  : 0;
  height  : 1px;
  width   : 50%;  /* or 100px */
  border-bottom:1px solid magenta;
}

Tags:

Css Example