border only half the side of a div

Related searches

If by adding a second div you mean no write it in the html you can simply use the ::after css property on your div like this:

div {
  width: 100px;
  height: 150px;
  background: black;
  position: relative;
}

div::after {
  content: "";
  position: absolute;
  width: 3px;
  right: -3px;
  height: 60%;
  background: red;
  top: 50%;
  transform: translate(-50%, -50%);
}
<div></div>

css border-left 50% height, You'd do the same on the right hand side, replacing the left property The text is visible, but the border color will be only at half of the div size. It’s necessary for the color blocks to have an outer div (.float-child) in order to add space and also have both blocks fit side by side. Well, what if we only had the .float-child divs without padding, and instead tried to add space by putting a margin-right value on the first block like this?


Try this, it's just css:

.addBorder {
  width: 100px;
  height: 100px;
  background-color: grey;
  position: relative;
}

.addBorder:before {
  content: "";
  position: absolute;
  width: 2px;
  height: 100%;
  bottom: 0;
  right: 0;
  background-color: #000;
  -webkit-transform: scaleY(0.5);
  transform: scaleY(0.5);
}
<div class="addBorder"></div>

Partial Borders with CSS, There is no such thing as border-length in CSS, which would have made this really easy to do. But anyway, if you want to have partial borders (a border that spans only half the length of the div e.g.), you can use the before/after pseudo selectors for this. Content on the left and content on the right. Basically two equal height columns are needed inside of a container. Each side takes up exactly half of the container, creating a distinct break between one. Like many things in CSS, there are a number of ways to go about this and we’re going to go over many of them right now!


By using pseudo code you can achieve your desire result, please have a look

.wrap{
 height: 100px;
 width: 100px; 
 position: relative;
 background: yellow;
}
.wrap::after {
    content: '';
    height: 50px;
    width: 2px;
    position: absolute;
    right: -1px;
    background: black;
    top: 50%;
    transform: translate(0, -50%);
}
<div class="wrap">lorem</div>

Half-Height Border, 3. width: 80px;. 4. position: relative;. 5. xborder-bottom: 2px solid #f51c40;. 6. background: #3beadc;. 7. } 8. . 9. div:after {. 10. content : "";. 11. position: absolute;. border-left-width: Optional. Specifies the width of the left border. Default value is "medium" border-left-style: Required. Specifies the style of the left border. Default value is "none" border-left-color: Optional. Specifies the color of the left border. Default value is the color of the text: initial: Sets this property to its default value.


Shorten the Length of the Border-Bottom With Pure CSS, This method of shortening the border-bottom is truly pure CSS. You want to add a border to the bottom of an element but you don't want it to be If you have enjoyed this post please checkout “Part 2” where I explain how to� Three values - border-radius: 15px 50px 30px; (first value applies to top-left corner, second value applies to top-right and bottom-left corners, and third value applies to bottom-right corner): Two values - border-radius: 15px 50px; (first value applies to top-left and bottom-right corners, and the second value applies to top-right and bottom


Left Half and Right Half Layout, Each side takes up exactly half of the container, creating a distinct break between Half of the background is set to one color and the other half another color. The border-right property is a shorthand property for (in the following order): border-right-width; border-right-style (required) border-right-color; If border-right-color is omitted, the color applied will be the color of the text.


border-color: red green; top and bottom borders are red; right and left borders are green; If the border-color property has one value: border-color: red; all four borders are red; Note: Always declare the border-style property before the border-color property. An element must have borders before you can change the color.