이 질문은 오래된 질문이지만 동일한 문제가있어서 this blog post from Front End Tricks And Magic이 나를 위해 일하므로 사람들이 여전히 궁금해 할 때를 대비하여 공유 할 것이라고 생각했습니다. 블로그의 요지는 입력이 readonly 속성을 가지고있는 경우에만 IE의 입력에서 줄임표를 사용할 수 있다는 것입니다.
분명히 많은 시나리오에서 입력에 읽기 전용 속성을 사용하지 않으려합니다. 어떤 경우에는 JavaScript를 사용하여 토글 할 수 있습니다. 이 코드는 블로그에서 직접 가져옵니다. 따라서이 답변이 도움이된다면 블로그를 확인하고 작성자에게 감사의 말을 남기는 것이 좋습니다.
HTML :
<div class="long-value-input-container">
<input type="text"
value="sdghkjsdghhjdfgjhdjghjdfhghjhgkdfgjnfkdgnjkndfgjknk" class="long-
value-input" readonly />
</div>
CSS : (jQuery를 사용하여)
.long-value-input {
width: 200px;
height: 30px;
padding: 0 10px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
자바 스크립트 자체가 나를 위해 속임수를 썼는지 입력에 text-overflow:ellipsis
설정
// making the input editable
$('.long-value-input').on('click', function() {
$(this).prop('readonly', '');
$(this).focus();
})
// making the input readonly
$('.long-value-input').on('blur', function() {
$(this).prop('readonly', 'readonly');
});
그냥'text-overflow : ellipsis'가'input' 엘리먼트에서 잘 작동합니다 (적어도 Chrome에서는) – talsraviv
대답은이 질문에 실제로 대답하지 않습니다. – jennEDVT