Changes the CSS of a HTML form if any of the form elements, are focused using the pseudo-class :focus-within. Sourced under a permissive license. Sourced under a permissive license.
Changes the CSS of a HTML form if any of the form elements, are focused using the pseudo-class :focus-within
<label for="username">Username:</label>
<input id="username" type="text" />
<label for="password">Password:</label>
<input id="password" type="text" />
border: 2px solid #52B882;
<form>
<label for="username">Username:</label>
<input id="username" type="text" />
<br />
<label for="password">Password:</label>
<input id="password" type="text" />
</form>
<style>
form {
border: 2px solid #52B882;
padding: 8px;
border-radius: 2px;
}
form:focus-within {
background: #7CF0BD;
}
label {
display: inline-block;
width: 72px;
}
input {
margin: 4px 12px;
}
</style>
<form>
<label for="username">Username:</label>
<input id="username" type="text" />
<br />
<label for="password">Password:</label>
<input id="password" type="text" />
</form>
<style>
form {
border: 2px solid #52B882;
padding: 8px;
border-radius: 2px;
}
form:focus-within {
background: #7CF0BD;
}
label {
display: inline-block;
width: 72px;
}
input {
margin: 4px 12px;
}
</style>
Tags: CSS, HTML, CSS, CSS code snippet, html code snippet, focus-within, form elements, CSS HTML
Image: Unsplash license
CC BY 4.0 added intro and tags – 30 Seconds of Code
RELATED WEBSITES AND SERVICES
These are paid advertisements or products and services ran by ourselves
Privacy preserving, cookieless website visitor tracking for your website completely free. unrive.io
Choose from over 100 quick & easy to use SEO, webmaster and developer tools. seoyex.com
Lorum Ipsum Generator, List Randomiser Tool, List Alphabetizer Tools, Case Converter Tools. seoyex.com
CSS Minifier, JS Minifier, HTML Formatter, CSS Formatter, JS Obfuscator Tools. unrivewebtools.com