Change text alignment after first line

I have text spanning multiple lines. The first line should start from left to right, but any extra text that does not fit in the first line should be aligned to the right.

Here is what I am trying to describe (with three paragraphs of two lines):

1. Lorem ipsum dolor sit amet, consectetur adipiscing    |
                                                    elit.|
2. Sed do eiusmod tempor incididunt ut labore et dolore  |
                                            magna aliqua.|
3. Ut enim ad minim veniam, quis nostrud exercitation ul-|
                     lamco laboris nisi ut aliquip ex ea.|

I tried this simple solution:

div {
  text-align: right;
}

div::first-line {
  text-align: left;
}

But that does not work. Forced display of the frame in the first line - div::first-line {display: block;}- does not help.

Closing the first line or any other line in a separate one spanor something to manipulate or do all the finished text is not an option; he must act automatically.

Is there a way to achieve this using CSS?

+4
source share
2 answers

div, text-align-last:

div {
   text-align: left;
   text-align-last: right;
   margin-bottom:10px;
}
<div>Fungus is common in temperate and tropical regions around the world. When young, it seems a puffball; in maturity, the outer layer of fruit body tissue splits open in a star shape, similar in appearance to the earthstars.</div>
<div>The fungus grows in mutual symbiosis with roots of various trees, especially in sandy soils. It can open up its rays to expose the spore sac in response to increased humidity</div>
<div>The rays have an irregularly cracked surface, while the spore case is pale brown and smooth with an irregular slit or tear at the top.</div>
+2

, .

p {
  margin-left: 3em; 
  text-indent: -3em;
}

, , , , , .

:

p { 
  text-align-last: right;
  margin-left: 3em; 
  text-indent: -3em 
 }
<p>I am a very long
sentence where my second line is longer.sentence where my second line is 
 longer. sentence where my second line is longer.sentence where my second line  is longer. sentence where my second line is longer.sentence where my second line  is longer. sentence where my second line is longer.sentence where my second line  is longer. sentence where my second line is longer.sentence where my second line  is longer. sentence where my second line is longer.</p>
<p>I am a very long
sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.sentence where my second line is longer.</p>

fiddle

0

Source: https://habr.com/ru/post/1688099/


All Articles