<p>
タグを兄弟の<input>
のfocus
でアニメーションしようとしていますが、動作しません。CSS兄弟セレクタがアニメ化されていません
私はコードペローを作成しました。
私はまた解決のためにJavascriptを使いたくありません。
https://codepen.io/ItsBrianAgar/pen/YrGVxW?editors=0100
HTML
<html lang="en"></html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700,900" rel="stylesheet"/>
<link href="assets/css/main.css" type="text/css" rel="stylesheet"/>
<title>myCoffee</title>
</head>
<body>
<main class="appContainer">
<div class="app">
<div class="sectionLogin">
<div class="logo"><img src="assets/images/logo.svg" alt="logo"/></div>
<div class="inputLogin">
<div class="textField"></div>
<div class="textField">
<p id="username">Username</p>
<input type="text" name="username"/>
</div>
<div class="textField">
<p id="password">Password</p>
<input type="password" name="password"/>
</div>
</div>
<div class="btnLogin">
<button>LOGIN</button>
</div>
<div class="btnSignup">
<button>SIGN UP</button>
</div>
</div>
</div>
</main>
</body>
CSS
input[name="username"]:focus ~ #username {
perspective: 1000;
transform: translate3d(-50%, 30px, 0);
opacity: 0;
transition: all 150ms ease-out; }
input[name="password"]:focus ~ #password {
perspective: 1000;
transform: translate3d(-50%, 30px, 0);
opacity: 0;
transition: all 150ms ease-out; }
ありがとう:
は、ここでの作業のデモです!私の髪を取り除こうとしていた。 –
ようこそ。 Btw、別のセレクタを使ってこの作業を行うことができます(置き換えはまだ必要です): 'input [name =" username "]:focus +#username'。それは後に来る最初の兄弟を* only *を選択します。 – voloshin