Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dotted line after text?

Tags:

css

I need a dotted line after the text. The dotted line should be till the end of the line. In the example below, after Organisation/Agency text, dotted line should start and should last till the end of the line. With the code below, I am getting the dotted line below the text as well which is not what I want.

Organisation/Agency.................................................

I tried as below.

.horizontal_dotted_line {
  border-bottom: 1px dotted black;
  width: 200px;
}
<div class="horizontal_dotted_line">
  Organisation/Agency
</div>

But the output I am getting is

Organisation/Agency
.................................................

My required output is Organisation/Agency........................................

like image 234
ChinnaR Avatar asked Apr 25 '17 12:04

ChinnaR


People also ask

How do you make a dotted line in text?

To use a line shortcut, first, open your document with Microsoft Word. Next, place your cursor where you want to add a dotted line in your document. Type the asterisk sign (“*”) three times in your document. Now, press Enter, and Word will convert your asterisks into a dotted line automatically.


2 Answers

You can use :after pseudo-element for dotted line and also set display: flex on parent element. With flex: 1 on pseudo element it will take rest of free width.

.horizontal_dotted_line {
  display: flex;
  width: 300px;
  border-right: 1px solid black;
  border-left: 1px solid black;
  padding: 5px;
} 
.horizontal_dotted_line:after {
  border-bottom: 1px dotted black;
  content: '';
  flex: 1;
}
<div class="horizontal_dotted_line">Organisation/Agency</div>
<div class="horizontal_dotted_line">Lorem</div>
like image 156
Nenad Vracar Avatar answered Dec 02 '22 21:12

Nenad Vracar


.horizontal_dotted_line{
     width: 200px;
     display : flex;
    } 
    .dot{
      flex: 1;
      border-bottom: 1px dotted black;
      height: 0.6em;
    }
<div class="horizontal_dotted_line">Organisation/Agency<span class="dot"></span></div>
like image 30
shivam Gupta Avatar answered Dec 02 '22 21:12

shivam Gupta