css transitions - Why transform:translatex in this css class does not move the div sideway? -
i want move div across screen. div set width:100% initially. when transformation starts, size of div seems have shrinked (the blue border wraps around text). why case?
before
after
here code example
http://codepen.io/kongakong/pen/mkzmmm
javascript:
$(document).ready(function () { init(); }); function init() { $('input').on('click', function () { $('.answer-text-2').closest('.answer').addclass('textout'); $('.answer-hide').addclass('textin'); }); } css
.row { } .hidden { display: none; } .answer-text-2 { color: red; opacity: 1; margin: auto; } .answer-text-2-new { color: blue; opacity: 0; margin: 500; } .textout { /* display: none; */ margin: -500; opacity: 0; width: '50%'; transition: 3s ease-in-out; } .answer-hide { border: 1px solid blue; width: '100%'; } .textin { position: absolute; margin: 0; left: 0; transform: translatex(10000px); transition: transform 5s ease-in-out; } html
<div class="contrainer"> <div> <input type='button' value="test"></input> </div> <div class="row"> <div class="answer"> <span class="answer-text-2">to disappear</span> </div> <div class="answer-hide">to move sideway </div> </div> </div>
well... width of div called answer-hide set auto, , it's position set static (as default values). when applying transformation div's position automatically changed absolute (as defined in spec) , width:auto block elements positioned absolutely shrink fit. fix that, sure, width property set, because width: 100%; not equal width: '100%'; :)
.answer-hide { border: 1px solid blue; width: 100%; } 

Comments
Post a Comment