2021년 7월 7일 수요일

rontend Coding Tips

1. Hiding an HTML element


<p hidden>This paragraph won't show up. It's hidden by HTML.</p>

2. Use the inset shorthand in CSS


div{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;

}
div{
position: absolute;
inset: 0;
}

 

3. Detect internet speed


navigator.connection.downlink;


4. Vibrate your phone


//vibrating the device for 500 millisecondswindow.navigator.vibrate(500);

5. Disable pull to refresh


body{
overscroll-behavior-y: contain;
}


6. Prevent the user from pasting text

<input type="text"></input><script>//selecting the input.
const input = document.querySelector('input');

//prevent the user to paste text by using the paste eventListener.
input.addEventListener("paste", function(e){
e.preventDefault()
})


</script>

댓글 없음:

댓글 쓰기