Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS add line after div

Tags:

css

I have this div here

<div class="example"></div>

and here is the CSS

.example
{
border: 5px solid #000;
height: 200px;
width: 400px;
position: relative;
}

What I am trying to do is add line after this box that is touching the right side of the box in the middle, how would I accomplish this?

like image 448
user979331 Avatar asked Mar 06 '17 20:03

user979331


People also ask

How do you add a line after CSS?

A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after or ::before . In the stylesheet, we use these pseudo-classes, with the HTML class or id, before or after the place where we want to insert a line-break. In myClass::after : Set the content property to "\a" (the new-line character).

Does div add new line?

It is an inline-level element and does not break to the next line unless its default behavior is changed. To make these examples easier to use and understand for all types of computer users, we're using the style attribute in the div.

How do I make text go to next line in CSS?

break-word: This is the actual CSS syntax that tells the browser to wrap a long text over to a new line. normal: It breaks each word at the normal points of separation within a DOM.

How do you put a line break in a div tag?

You can insert line breaks in HTML with the <br> tag, which is equivalent to a carriage return on a keyboard.


1 Answers

You need to use ::after pseudo-element

.example {
  border: 5px solid #000;
  height: 200px;
  width: 400px;
  position: relative;
  box-sizing: border-box;
}
.example::after {
  content: " ";
  display: block;
  position: absolute;
  height: 5px;
  background: black;
  width: 40px;
  left: 100%;
  top: calc(50% - 2px);
}
<div class="example"></div>
like image 98
Banzay Avatar answered Oct 13 '22 00:10

Banzay