<div class="container"> <h1>Sign in</h1> <div class="editor-field editor-field__textbox"> <div class="editor-field__label-container"> <label class="editor-field__label">Name</label> </div> <div class="editor-field__container"> <input type="text" class="editor-field__input" onfocus="generateNoise(this, 'input')" onblur="removeNoise(this, 'input')" /> </div> <span class="editor-field__bottom"></span> <div class="editor-field__noise"></div> </div> <div class="editor-field editor-field__textbox"> <div class="editor-field__label-container"> <label class="editor-field__label">Password</label> </div> <div class="editor-field__container"> <input type="password" class="editor-field__input" onfocus="generateNoise(this, 'input')" onblur="removeNoise(this, 'input')" /> </div> <span class="editor-field__bottom"></span> <div class="editor-field__noise"></div> </div> <div class="btn btn--primary" onmouseover="generateNoise(this, 'button')" onmouseout="removeNoise(this, 'button')"> <div class="btn__container"> Login </div> <div class="btn__bottom"></div> <div class="btn__noise"></div> </div> </div> * { box-sizing: border-box; } html, body, input { font-family: "Tomorrow"; font-weight: 500; height: 100%; } body { display: flex; align-items: center; justify-content: center; font-size: 13.5px !important; color: #B3B5D2; background: #0F1020; } h1 { font-size: 24px; flex-grow: 1; flex-shrink: 1; display: flex; width: 100%; padding: 0px 0 56px 0; } .container { width: 300px; margin: auto; display: flex; flex-direction: column; align-items: flex-end; margin-top: 70px; } .editor-field { width: 300px; height: 64px; position: relative; margin: 14px 0; } .editor-field .noise__el { fill: #70719C; } .editor-field__noise { position: absolute; bottom: -2px; width: 100%; height: calc(100% + 2px); z-index: 2; pointer-events: none; } .editor-field__container { clip-path: polygon(0% 0%, calc(100% - 8px) 0, 100% 8px, 100% 100%, 95% 100%, calc(0% + 8px) 100%, 0% calc(100% - 8px), 0% calc(100% + 8px)); border: 2px solid #5E5F84; width: 100%; height: 48px; position: absolute; bottom: 2px; } .editor-field__container:before, .editor-field__container:after { content: ""; height: 2px; width: 11.5px; background: #5E5F84; display: block; position: absolute; z-index: 1; -webkit-transform: rotate(45deg); transform: rotate(45deg); border-radius: 5px; } .editor-field__container:before { right: -3.1px; top: 1.6px; } .editor-field__container:after { left: -3.1px; bottom: 1.6px; } .editor-field__bottom { position: absolute; content: ""; display: block; height: 2px; width: 30%; background: #5E5F84; right: 0px; clip-path: polygon(0 0, 100% 0%, 100% 100%, calc(0% + 2px) 100%); bottom: 0px; } .editor-field__label-container { position: absolute; top: 0px; } .editor-field__label-container:after { position: absolute; content: ""; display: block; height: 2px; width: 32px; background: #5E5F84; right: -29px; -webkit-clip-path: polygon(0 0, calc(100% - 2px) 0%, 100% 100%, 22% 100%); clip-path: polygon(0 0, calc(100% - 2px) 0%, 100% 100%, 0% 100%); bottom: 2px; } .editor-field__label { position: relative; display: block; height: 16px; width: auto; background: #5E5F84; left: 0px; color: #0F1020; font-size: 9px; text-transform: uppercase; letter-spacing: 1.25px; font-weight: 600; padding: 0 24px 0 16px; display: flex; align-items: center; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 100%, 0% 100%); } .editor-field__input { width: 100%; height: 100%; border: none; outline: none; background: #0F1020; color: #B3B5D2; padding: 8px 16px; letter-spacing: 0.2px; } .editor-field__input:focus { animation: 0.05s infinite alternate blink; } @keyframes blink { from { background: #0F1020; } to { background: #111223; } } .editor-field:hover .editor-field__bottom, .editor-field.is-focused .editor-field__bottom { background: #70719C; } .editor-field:hover .editor-field__container, .editor-field.is-focused .editor-field__container { border-color: #70719C; } .editor-field:hover .editor-field__container:after, .editor-field:hover .editor-field__container:before, .editor-field.is-focused .editor-field__container:after, .editor-field.is-focused .editor-field__container:before { background: #70719C !important; } .editor-field:hover .editor-field__label-container:after, .editor-field.is-focused .editor-field__label-container:after { background: #70719C; } .editor-field:hover .editor-field__label, .editor-field:hover .editor-field__helper, .editor-field.is-focused .editor-field__label, .editor-field.is-focused .editor-field__helper { background: #70719C; } .btn { display: inline-block; position: relative; height: 50px; margin-top: 32px; cursor: pointer; } .btn__noise { position: absolute; top: -28%; height: 66px; width: 100%; pointer-events: none; } .btn--primary .btn__container { background: #383CAB; border-color: #5054c6; display: flex; align-items: center; line-height: 10px; pointer-events: none; color: #dedff4; } .btn--primary .noise__el { fill: #5054c6; } .btn--primary:hover .btn__container { background: #34389f; border-color: #494dc3; } .btn--primary:hover .btn__bottom { background: #34389f; border-color: #494dc3; } .btn--primary:active .btn__container { background: #2e318c; border-color: #3b3fb3; color: #c3c5ec; } .btn--primary:active .btn__bottom { background: #2e318c; border-color: #3b3fb3; } .btn:before, .btn:after { content: ""; height: 2px; width: 11px; background: #5054c6; display: block; position: absolute; z-index: 1; -webkit-transform: rotate(45deg); transform: rotate(45deg); border-radius: 2px; border-radius: 2px; } .btn:before { right: -1.07px; top: 4px; } .btn:after { left: -1.07px; bottom: 6px; } .btn__bottom { position: absolute; content: ""; display: block; height: 4px; width: 50%; background: #383CAB; pointer-events: none; right: 0px; bottom: 0px; clip-path: polygon(0 0, 100% 0%, 100% 100%, calc(0% + 4px) 100%); border-bottom: 2px solid #5054c6; border-right: 2px solid #5054c6; } .btn__bottom:before { content: ""; height: 2px; width: 11px; background: #5054c6; display: block; position: absolute; left: -5px; bottom: 2px; z-index: 1; -webkit-transform: rotate(45deg); transform: rotate(45deg); } .btn__container { height: 100%; background: none; border: none; color: white; padding: 0 24px; height: 48px; border: 2px solid; clip-path: polygon(0% 0%, calc(100% - 8px) 0, 100% 8px, 100% 100%, 95% 100%, calc(0% + 8px) 100%, 0% calc(100% - 8px), 0% 20%); } const removeNoise = ({ offsetParent:{offsetParent}, lastElementChild }, type) => { let inputNoise; if (type == "input") { inputNoise = offsetParent.lastElementChild; offsetParent.classList.remove("is-focused"); } else { inputNoise = lastElementChild; } inputNoise.removeChild(inputNoise.childNodes[0]); }; const createSvg = (config) => { let svgGroup = document.createElementNS( "http://www.w3.org/2000/svg", "svg" ); svgGroup.setAttribute("x", config.svgGroupX); svgGroup.setAttribute("y", config.svgGroupY); let rect = document.createElementNS( "http://www.w3.org/2000/svg", "rect" ); rect.setAttribute("x", config.rectX); rect.setAttribute("y", config.rectY); rect.setAttribute("width", config.noiseWidth); rect.setAttribute("height", config.noiseHeight); rect.setAttribute("class", "noise__el"); svgGroup.appendChild(rect); let rectOnBorder = document.createElementNS( "http://www.w3.org/2000/svg", "rect" ); rectOnBorder.setAttribute("x", config.rectBorderX); rectOnBorder.setAttribute("y", config.rectBorderY); rectOnBorder.setAttribute("width", config.noiseWidth); rectOnBorder.setAttribute("height", config.noiseHeight); rectOnBorder.setAttribute("fill", "rgb(15, 16, 32)"); svgGroup.appendChild(rectOnBorder); let animate = document.createElementNS( "http://www.w3.org/2000/svg", "animate" ); animate.setAttribute("attributeType", "CSS"); animate.setAttribute("attributeName", "opacity"); animate.setAttribute("id", config.id); animate.setAttribute("from", "0"); animate.setAttribute("to", "1"); animate.setAttribute("dur", `${Math.random() + 0.1}s`); animate.setAttribute("repeatCount", "indefinite"); animate.setAttribute( "begin", `${Math.random() + 0.1}s;${config.id}.end+${Math.random() + 0.1}s` ); svgGroup.appendChild(animate); return svgGroup; }; const generateNoise = (e, type) => { const svg = document.createElementNS( "http://www.w3.org/2000/svg", "svg" ); let input, inputNoise, noiseColor; if (type == "input") { input = e.offsetParent; e.parentElement.parentElement.classList.add("is-focused"); inputNoise = e.parentElement.parentElement.lastElementChild; noiseColor = "rgb(112, 113, 156)"; } else { input = e; inputNoise = e.lastElementChild; noiseColor = "rgb(73, 77, 195)"; } let inputHeight = input.offsetHeight; let inputWidth = input.offsetWidth; svg.setAttribute("width", "300"); svg.setAttribute("height", "66"); let maxNumberOfHorizontalNoise = Math.round(inputWidth / inputHeight); let maxNumberOfVerticalNoise = Math.round(inputHeight / 10 / 2); let verticalNoiseToGenerateBottom = Math.floor( Math.random() * (maxNumberOfHorizontalNoise - 1) + 1 ); let commonVerticalConfig = { inputWidth, noiseHeight: 2, rectX: "4", rectBorderX: "4", rectBorderY: "14", noiseColor, }; let commonHorizontalConfig = { inputWidth, maxNoiseWidth: 8, minNoiseWidth: 2, noiseWidth: 2, rectBorderY: 14, noiseColor, }; for (let i = 0; i <= verticalNoiseToGenerateBottom; i++) { svg.appendChild( createSvg({ ...commonVerticalConfig, noiseWidth: Math.floor(Math.random() * (16 - 4) + 4), svgGroupX: Math.floor(Math.random() * (inputWidth - 1) + 1), rectY: Math.floor(Math.random() * (16 - 8) + 8), svgGroupY: 46, id: `bottom${i}`, }) ); } let verticalNoiseToGenerateTop = Math.floor( Math.random() * (maxNumberOfHorizontalNoise - 1) + 1 ); for (let i = 0; i <= verticalNoiseToGenerateTop; i++) { svg.appendChild( createSvg({ ...commonVerticalConfig, noiseWidth: Math.floor(Math.random() * (16 - 4) + 4), svgGroupX: Math.floor(Math.random() * (inputWidth - 1) + 1), rectY: Math.floor(Math.random() * (20 - 8) + 8), svgGroupY: 0, id: `top${i}`, }) ); } for (let i = 0; i <= maxNumberOfVerticalNoise; i++) { svg.appendChild( createSvg({ ...commonHorizontalConfig, noiseHeight: Math.floor(Math.random() * (8 - 2) + 2), rectX: "2", rectY: Math.floor(Math.random() * (20 - 12) + 12), svgGroupX: 0, svgGroupY: Math.floor(Math.random() * (20 - 1) + 1), id: `left${i}`, rectBorderX: 0, }) ); } for (let i = 0; i <= maxNumberOfVerticalNoise; i++) { svg.appendChild( createSvg({ ...commonHorizontalConfig, noiseHeight: Math.floor(Math.random() * (8 - 2) + 2), rectX: "0", rectY: Math.floor(Math.random() * (20 - 12) + 12), svgGroupX: inputWidth - 4, svgGroupY: Math.floor(Math.random() * (20 - 5) + 5), id: `right${i}`, rectBorderX: 2, }) ); } inputNoise.appendChild(svg); }; Навигация по записям Material Design Sign In Form Login, Register form