나는 막혔고, 이것에 대한 해결책을 찾아 다녔다. 페이지로드시에는 입력 값이 opacity: 0
이고 나중에 전체 불투명도가 있지만 인라인 대신 페이지 아래로 이동하려면 블록으로 표시 할 입력이 필요합니다. 이렇게하면 .block
클래스의 페이드를 막을 수 있습니다. 어쨌든 입력이 블럭 방식으로되어 여전히 CSS로 페이드 인 할 수 있습니까?CSS를 사용하여 블록을 페이드 인하도록 입력 세트를 얻는 방법
또한 예제에서 레이블을 입력 위에 놓고 페이지 중앙에 표시되도록 레이블/입력을 표시 블록에 가져 오는 방법이 있습니까?
This fiddle demonstrates it best
$(function() {
var elems = $('.intro input').on('keypress', function() {
if ($(this).val().trim().length > 2) {
$(this).parent().next('label').addClass('block');
}
$('#intro-button').toggle(
elems.filter(function() {
return this.value.trim() !== "";
}).length === elems.length
)
});
});
.intro {
\t opacity: 0;
}
.info-input {
\t padding: 10px 15px;
\t margin: 40px auto;
}
.intro:first-child {
\t display: block;
\t opacity: 1;
}
.block {
\t display: block;
\t visability: visible;
\t opacity: 1;
-webkit-animation: fadein 1s ease-in;
-moz-animation: fadein 1s ease-in;
animation: fadein 1s ease-in;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<label class="intro">What is your name?
\t \t \t \t <input id="name" type="text" class="info-input">
\t \t \t </label>
\t \t \t <label class="intro">What is your email address?
\t \t \t \t <input id="email" type="email" class="info-input">
\t \t \t </label> \t
\t \t \t <label class="intro">What is your title?
\t \t \t \t <input id="title" type="text" class="info-input">
\t \t \t </label>
는 당신이 필요하지 않습니다, block''로 레이블을 표시하려면 입력 필드를'label' 안에 감싸고,'for = "# id"'속성만을 사용하면됩니다.'# id'는 상대 입력 필드의'id'를, 이렇게 ** [jsFiddle **] (https://jsfiddle.net/Mi_Creativity/xfbLskhn/5/) –
이것은 마지막 기능적인 [fiddle] (https://jsfiddle.net/Mi_Creativity/60vauuk2/2/)입니다. –
@ Mi-Creativity 감사합니다. 이것은 완벽합니다! 대답을 떠나 자유롭게 – Becky