//创建style元素
var hoverAttributionStyle = document.createElement("style");
//指定style元素的类型
hoverAttributionStyle.type = "text/css";
//指定style元素的内容
hoverAttributionStyle.innerHTML =
".esri-truncated-attribution:hover {" + "white-space: normal;" + "}";
//得到head并放到末尾
document.getElementsByTagName("head")[0].appendChild(hoverAttributionStyle);
// 为指定dom元素添加类样式
DomUtil.addClass(
map.attributionControl._container,
"esri-truncated-attribution:hover"
);
attributionStyle.innerHTML =
".esri-truncated-attribution {" +
"vertical-align: -3px;" +
"white-space: nowrap;" + // 不换行
"overflow: hidden;" +
"text-overflow: ellipsis;" + // 溢出时显示省略符号来代表被修剪的文本
"display: inline-block;" +
"transition: 0s white-space;" +
"transition-delay: 1s;" +
"max-width: " +
calcAttributionWidth(map) +
";" +
"}";
网友评论