[英]How do I keep inline-block and table-cell elements on same line during css transitions?
See my codepen: http://codepen.io/maidson/pen/RNQXMb (relevant SCSS at bottom) 请参阅我的代码笔: http ://codepen.io/maidson/pen/RNQXMb(相关的SCSS在底部)
HTML 的HTML
<div class="email">
<div id="thanks"><span>Thanks!</span></div>
<input id="text"></input>
<button id="btn" data-text-swap="OK">
Stay Informed
</button>
</div>
SCSS SCSS
.email{
display: table;
margin: 0 auto;
width: 400px;
input, button{
display: table-cell;
height: 60px;
}
#thanks{
width:0px;
@include vendorize(transition, $transition);
background: #fff;
color: #000;
white-space: nowrap;
overflow-x: hidden;
height: 60px;
display: inline-block;
text-align: center;
line-height: 60px;
span{
margin: 0 auto;
}
}
input{
width: 0;
margin-left: 25%;
@include vendorize(transition, $transition);
background: #fff;
color: #000;
}
button{
width: 50%;
@include vendorize(transition, $transition);
white-space: nowrap;
}
}
.email.focus{
input{
width: 85%;
margin-left: 0%;
}
button{
width: 15%;
}
}
.email.submit{
#thanks{
width: 100%;
background: #ccc;
}
input{
width: 0%;
margin-left: 100%;
background-color: #ccc;
}
button{
width: 0%;
}
}
I have a 2-part animation that I want to guide a user through email registration in a single box. 我有一个分为两部分的动画,我想通过一个框引导用户进行电子邮件注册。 Currently, some js is used to assign class="focus" on first click, and replace that with class="submit" on second click.
当前,一些js用于在第一次单击时分配class =“ focus”,并在第二次单击时将其替换为class =“ submit”。
I want this entire sequence to remain on a single row, and I want the last transition to wipe left-to-right (after clicking "ok"). 我希望整个序列都保留在单个行中,并且我希望最后一个过渡从左到右擦除(单击“确定”后)。 Currently, the #thanks div causes the other two elements to spill onto a second row.
当前,#thanks div导致其他两个元素溢出到第二行。 I want to prevent that from happening while retaining the transition animation.
我想防止这种情况的发生,同时保留过渡动画。
What am I missing here? 我在这里想念什么? Thanks!
谢谢!
At the bottom of your CSS, try changing the margin-left to 0%: 在CSS底部,尝试将左边距更改为0%:
.email.submit{
#thanks{
width: 100%;
background: #ccc;
}
input{
width: 0%;
margin-left: 0%;
background-color: #ccc;
}
button{
width: 0%;
}
}
You can do it by adding positioning - 您可以通过添加定位来做到这一点-
.email{
position:relative;
#thanks{
position:absolute;
}
}
Thats it :) 而已 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.