2013-08-30 4 views
1

텍스트 앞에 "..."을 입력하고 div를 채울 때 마지막 부분 만 표시해야합니다. enter image description here"방향"이 "rtl"로 설정된 경우 "텍스트 오버플로"를 사용해야합니다.

은 사용하지 않고, CSS는에 의해 할 수 있나요 : http://jsfiddle.net/CBUH4/5/ 여기

내가해야 할 것입니다 : 그것은 정상시

그리고 여기에

<span class="file-upload-status" style="max-width:200px"> 
    C:\fakepath\996571_1398802860346752_2094565473_n.jpg 
</span> 
<br/> 
<span class="file-upload-status" style="max-width:200px"> 
    C:\fakepath\1.jpg 
</span> 

내가 무엇을 가지고 아무것도하지 않고 JavaScript 또는 jQuery. 이 같은

+0

간단한 '텍스트 오버플로 : 줄임표;'는 Firefox에서 작동하지만 다른 브라우저에서는 사용자가 언급 한 방식대로 작동하지 않습니다. – Harry

+0

'text-overflow : ellipsis; '를 시도했지만'direction : rtl;'에 피해를 입혔습니다. –

+0

CSS에서는 가능하지 않다고 생각하지만 JS로 괜찮 으면 해결책을 제시 할 수 있습니다. – Harry

답변

2

아마 뭔가 : http://jsfiddle.net/CBUH4/8/

white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
+0

원 포인트 메이트. Firefox에서 텍스트가 "One Two Three"이고 "생략 부호"가 적용되면 "Two Three"가됩니다. 그러나 다른 브라우저에서는 "One Th Th"가됩니다. 사용자는 전자를 원한다. – Harry

+0

@Harry가 크롬에서 잘 작동합니다. –

+0

@ Mr_Green : 이상합니다. Chrome 버전 31.0.1612.2 dev-m을 사용하고 있습니다. 괜찮 으면 작동합니다. :) – Harry

1

이 난 그냥 CSS를 사용하여 가지고 할 수있는 가장 가까운 솔루션입니다. 여전히 span 엘리먼트의 폭과 거의 같은 복수의 .을 사용할 필요가 있다는 단점이 있습니다.

Fiddle

HTML

<span class="file-upload-status ellipsis" style="max-width:200px"> 
    C:\fakepath\996571_1398802860346752_2094565473_n.jpg 
</span> 

<br/> 
<span class="file-upload-status" style="max-width:200px"> 
    C:\fakepath\1.jpg 
</span> 

CSS

.file-upload-status { 
    font-weight: bold; 
    font-size: 16px; 
    color: #888; 
    background: #fff; 
    border-radius: 7px; 
    height: 27px; 
    border: 1px solid #ccc; 
    padding-left: 5px; 
    padding-right: 5px; 
    white-space: nowrap; 
    overflow: hidden; 
    direction: rtl; 
    display:inline-block; 
    width: 200px; 
    position: relative; 
} 
.file-upload-status:after { 
    content:"................................."; 
    color: white; 
    position: relative; 
    background-color: white; 
    z-index: 2; 
} 
.file-upload-status:before { 
    content:"..."; 
    position:absolute; 
    background-color: white; 
    left: 0px; 
    top: 0px; 
    z-index: 1; 
} 

제안 : D

: 가능한 한 많은 점을 부여3210
+0

OP에 표시되는 이미지를 보아서, 그냥 조금 수정했습니다 (즉, 줄임표로 div에 대해서만 rtl을 적용합니다). [** fiddle **] (http://jsfiddle.net/hari_shanx/CBUH4/11/). 괜찮 으면 답변에 추가하십시오 :) 샘플 +1. – Harry

+0

좋습니다. 하지만 그것에서 값이 길 때'생략 부호 '클래스를 추가하려면 Javascript를 사용해야합니다 :) –

+0

[링크] http://oi44.tinypic.com/2vhzotf.jpg –