Preface Sometimes when <style type="text/css" media="screen"> .test { height: 30vmin; width: 30vmin; background: lightblue; box-sizing: border-box; } .test:hover { border: 5px solid black; } </style> <div class="test"> this is a div. </div> The reason here is obvious. The size of our element has not changed (if the element width and height are not set or Adding a border to an element The sudden appearance of the border changes the original layout and moves the content. In this case, we can just let the border exist in the previous layout. .test { height: 30vmin; width: 30vmin; background: lightblue; border: 5px solid transparent; box-sizing: border-box; } .test:hover { border: 5px solid black; } Using box-shadow Using .test:hover { /* border: 5px solid black; */ box-shadow: 0 0 0 5px black; outline: 5px solid black; } Use padding We can reserve space for .test { height: 30vmin; width: 30vmin; background: lightblue; box-sizing: border-box; padding: 5px; } .test:hover { padding: 0; border: 5px solid black; } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Teach you to implement a simple promise step by step
>>: Detailed tutorial on integrating Apache Tomcat with IDEA editor
Three ways to set borders in HTML border-width: 1...
1. Question: I have been doing insert operations ...
Mysql multiple unrelated tables query data and pa...
Table of contents Scene Introduction Plugin Imple...
1. First install the pagoda Installation requirem...
Recently, the company purchased a DELL R730 serve...
MySQL is a multi-user managed database that can a...
Recently, I have a project that requires using ifr...
Table of contents 1. Click on the menu to jump 1....
MySQL's CAST() and CONVERT() functions can be...
Web Services are concerned with application-to-ap...
Install fastdfs on Docker Mount directory -v /e/f...
What is a tree in web design? Simply put, clicking...
Today I sent a small tool for Ubuntu to a custome...
Copy code The code is as follows: <!DOCTYPE ht...