javascript - Chrome bug with animating ellipsis text that changes colour. the text moves to the right -
this example of problem having. clicking on middle anchor causes move right.
var anchors = document.getelementsbytagname('a'); var onselect = function () { var i, a; (i = 0; < anchors.length; += 1) { = anchors[i]; if (a === this) continue; a.classlist.remove('selected'); } this.classlist.toggle('selected'); }; (function () { (var = 0; < anchors.length; += 1) { anchors[i].addeventlistener('click', onselect); } }());
.table { display: table; background-color: indigo; width: 600px; } .row { display: table-row; background-color: seagreen; } .cell { display: table-cell; text-align: center; vertical-align: middle; } { padding: 10px; background-color: lightblue; display: inline-block; transition: 0.5s ease; width: 140px; height: 30px; line-height: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: black; } a.selected { background-color: blue; color: white; }
<div class="table"> <div class="row"> <div class="cell"> <a href="#">a new hope</a> </div> <div class="cell"> <a href="#">the empire strikes back</a> </div> <div class="cell"> <a href="#">return of jedi</a> </div> </div> </div>
if don't change colour of text, or remove ellipsis, doesn't happen. can reproduce in chrome, assume issue browser.
wondered if there known work around. chrome version 53.0.2785.143 m
same example in jsfiddle: https://jsfiddle.net/f5k8p3tv/
set display:inline-block
display:block
on anchor element.
somehow tries re-assess it's "inline" position , causes shift. since working table, not need inline feature because each element has fixed position within table row.
var anchors = document.getelementsbytagname('a'); var onselect = function () { var i, a; (i = 0; < anchors.length; += 1) { = anchors[i]; if (a === this) continue; a.classlist.remove('selected'); } this.classlist.toggle('selected'); }; (function () { (var = 0; < anchors.length; += 1) { anchors[i].addeventlistener('click', onselect); } }());
.table { display: table; background-color: indigo; width: 600px; } .row { display: table-row; background-color: seagreen; } .cell { display: table-cell; text-align: center; vertical-align: middle; } { padding: 10px; background-color: lightblue; display: block; transition: 0.5s ease; width: 140px; height: 30px; line-height: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: black; } a.selected { background-color: blue; color: white; }
<div class="table"> <div class="row"> <div class="cell"> <a href="#">a new hope</a> </div> <div class="cell"> <a href="#">the empire strikes back</a> </div> <div class="cell"> <a href="#">return of jedi</a> </div> </div> </div>
Comments
Post a Comment