我的网站上有一个面包屑(|
象征着我所拥有的区域):
| Home -> Some thing -> Some deeper thing |
目前,它已设置overflow: hidden
,因此当它变得太长时,会导致:
| Home -> Some thing -> Some deeper thing -> Some page with very long and very import|
我想要实现的是隐藏文本的开头而不是结尾,所以它应该是:
| me thing -> Some deeper thing -> Some page with very long and very important title |
怎么做?
答案 0 :(得分:1)
你可以使用2 divs
和一些简单的javascript这样做:
window.onload = function(){
var inner = document.getElementById("inner").offsetWidth;
var outer = document.getElementById("outer").offsetWidth;
if(outer > inner)
document.getElementById("inner").style.left = 0;
}

#outer {
overflow: hidden;
width: 500px;
height: 20px;
position: absolute;
}
#inner {
white-space: nowrap;
position: absolute;
right: 0;
}

<div id="outer"><div id="inner">Home -> Some thing -> Some deeper thing -> Some page with very long and very important title</div></div>
&#13;