이 난 그냥 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
간단한 '텍스트 오버플로 : 줄임표;'는 Firefox에서 작동하지만 다른 브라우저에서는 사용자가 언급 한 방식대로 작동하지 않습니다. – Harry
'text-overflow : ellipsis; '를 시도했지만'direction : rtl;'에 피해를 입혔습니다. –
CSS에서는 가능하지 않다고 생각하지만 JS로 괜찮 으면 해결책을 제시 할 수 있습니다. – Harry