2012-07-09 2 views
0

<span> 태그 .lastMessageLink이 있고 그 안에 <a>.lastMessageText이 있습니다. .lastMessageText에 넣을 수있는 텍스트는 몇 자만큼 짧거나 한 단락 일 수 있지만 최대 4 줄의 텍스트를 표시하려고합니다.스팬 태그 내 href에 대한 줄 수 지정

작동하지 않는 내가 가진 현재의 스타일은 이것이다 :

.lastMessageLink { 
    line-height: 1em; 
    text-overflow: ellipsis; 
    max-height: 4em; 
    overflow: hidden; 
} 

.lastMessageText { 
    color: black; 
    word-wrap: break-word; 
} 

을 그리고 여기에 HTML입니다 :

<span class="lastMessageLink"> 
    <a id="undefined" class="lastMessageText" title="now i need a really really long message so that i can test this whole multiple lines thing which is gonna be a problem and a trickier problem than we had initially thought. it's interesting because you'd think a couple css styles would be enough, but we might have to go by characters" href="#conversation:cid=10714&amp;mid=10735"> 
     now i need a really really long message so that i can test this whole multiple lines thing which is gonna be a problem and a trickier problem than we had initially thought. it's interesting because you'd think a couple css styles would be enough, but we might have to go by characters 
    </a> 
</span> 

내가 HTML/CSS: Specify number of lines inside <span> 살펴 보았다, Limit text length to n lines using CSS, Using CSS text-overflow to vary the number of lines of text within an element of a set heightHow to set element height for a fixed number of lines of text .

jQuery 나 Javascript를 사용하는 솔루션에 열려 있습니다. CSS만으로는 진행할 수 없었습니다.

+2

잘''태그는 (** 반대로 스타일을 지정하지 않고) ** 인라인 ** 요소이므로 치수를 제한하는 것이 의미가 없습니다. 이를 무시하고'display : block' 또는'display : inline-block'으로 만든 다음'max-height' 설정을 사용하여 높이를 제한 할 수 있습니다. HTML/CSS는 "텍스트 줄"개념을 너무 잘 이해하지 못합니다. – Pointy

+0

HTML 부분을 게시 할 수 있습니까? 그것이 작동하지 않는다고 할 때, 어떻게 작동하지 않는가? (줄 수, 오버플로, 표시되지 않는지 등) – Rodolfo

+1

@Pointy는 이것을 무시하고 그것들을'display : block'으로 만들 수있다. – Rodolfo

답변

1

변화 <div>-<span> 그 트릭을 할해야합니다 나는 웹에

+0

정말요? 왜 그런지 알아? –

+0

div는 최대 높이 규칙을 따르는 블럭 레벨 요소이기 때문에, 현재 가지고있는 수액은 어떤 이유로 높이를 설정할 수없는 인라인 요소입니다. 스팬 CSS를 사용하여 속성 표시 : 그것에 블록 – Gilsham

2

연구를 생각뿐만 아니라 일부 former stack overflow questions (here also는) white-space: nowrap이 설정되어 있지 않으면, ellipsis이 작동하지 않는 것을 나타냅니다. 그것은 물론 을 의미하며 한 줄의 텍스트 인에서만 작동합니다.

을 유발할 수있는 JQuery와 플러그인

는 보정하기 :

세 개의 점 http://tpgblog.com/2009/12/21/threedots-the-jquery-ellipsis-plugin/

jQuery를 텍스트 오버플로 http://www.bramstein.com/projects/text-overflow/

자동 줄임표 http://pvdspek.github.com/jquery.autoellipsis/