


His source code can easily be found here, it’s free to copy and hasn’t been patented. He lay on his warm bed, waiting for a good night sleep and those next challenges to come. Anyway, he closed his laptop, unlike other times, this time he closed it with joy. bottom-right: new_width = element_original_width + (mouseX - original_mouseX) new_height = element_original_height + (mouseY - original_mouseY) bottom-left: new_width = element_original_width - (mouseX - original_mouseX) new_height = element_original_height + (mouseY - original_mouseY) new_x = element_original_x - (mouseX - original_mouseX) top-right: new_width = element_original_width + (mouseX - original_mouseX) new_height = element_original_height - (mouseY - original_mouseY) new_y = element_original_y + (mouseY - original_mouseY) top-left: new_width = element_original_width - (mouseX - original_mouseX) new_height = element_original_height - (mouseY - original_mouseY) new_x = element_original_x + (mouseX - original_mouseX) new_y = element_original_y + (mouseY - original_mouseY)Īll the clock’s arrows pointed up to the sky, his neck hurts, his back burns, his mind satisfied, his mom urges him to go to bed, his girlfriend urges him to go to bed, well…if he has one. Without wasting any seconds, he wrote down 4 formulas for 4 different resizers (he has changed his formula for the bottom-right resizer to use the same method as other resizers. Output: Before clicking the button: After clicking the button: Method 2: Using clientHeight property: The clientHeight property of an element is a read-only property and used to return the height of an element in pixels. His laughter stopped when he realized that he can use the same formula for resizing the height of the element. “Huge success!” - He laughed loudly in the middle of the night like a mad scientist. “First, the white square on the black background” - He typed in those first lines of css code into the file body, html He’s actually using Sass for his project, but to facilitate major readers, I’ll write it in plain css. One hand on the keyboard, his other hand quickly controls the mouse to switch to the css file. Closed his eyes, everything was clear in his mind, a white rectangle on a black background with 4 white circle resizer at 4 of its corners. “That should do it” - He laid back to his pillow before moving on to the css code. “It should be a square with 4 resizers at its 4 corners” - His thought went through his naive brain and passed down to his hand then finally command all 8 of his 10 fingers to type the correct letter for the html structure. Like every other start, he first created a html structure for the “resizable div”.
.jpg)
His arrogant when up, “can’t be that hard” - He said with a smile on his face without knowing that the problem he’s about to encounter is going to take a great deal of his knowledge and experience to solve. As he was scrolling aimlessly through a long list of JavaScript functions, he stumbled on an empty function named makeResizableDiv(div). “Perfect time for programming” - Hung said. It was a quiet night with a perfect temperature for the brain to give 100%. Making a resizable div in JS is not easy as you think
