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
Optimizing large amounts of database data is a hu...
Table of contents Preface What are asynchronous i...
Why? The simplest way to put it is that pixels are...
If you're collecting information from your us...
I knew before that to synchronously obtain the re...
1. Background Generally, in a data warehouse envi...
The PC version of React was refactored to use Ama...
When it comes to tool-type websites, we first hav...
This article shares the specific code of jQuery...
I searched for three-level linkage on the Interne...
Method 1: Use the SET PASSWORD command mysql> ...
css-vars-ponyfill When using CSS variables to ach...
Table of contents The first step of optimization:...
There are too many articles about xhtml+css websi...
question: When developing the Alice management sy...