문제

I have question about css selector. I want to select all sentences after first sentence in container. For first sentence there is no problem:

 :first-line

But I can't find way to select sentences "after first line". I tried something like this but it don't working.

:not(:first-line)

Here is fiddle with selected first sentence but this don't solve my problem. http://jsfiddle.net/zono/2bDx8/ Best regards.

도움이 되었습니까?

해결책 2

The trick is that the height of each line defaults to 1em. Setting the max height and overflow hidden will only show the first line of the sentence.

http://jsfiddle.net/AqaLJ/2/

p  {
 max-height: 1em;
 overflow: hidden;
}

Another approach could be to use text-overflow: ellipsis. This is much more user-friendly as it indicates that the sentence has more text and is trimmed.
http://jsfiddle.net/Wws6L/11/

p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

다른 팁

First of all, ::first-line doesn't select the first sentence, it selects the first line, whose end is marked by a line break. That said, I don't think there is one selector for what you demand, but here's a neat trick:

.linesOfText {       /* :not(:first-line)) */
   background-color: blue;
}

.linesOfText::first-line{
    background:white;
}

DEMO

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top