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
This article example shares the specific code of ...
<br />When the page contains <img src=&qu...
In actual projects, the up and down scroll bars a...
1. Sometimes we use ES Due to limited resources o...
Table of contents 1. Overview 2. Application Exam...
Table of contents In vue2 In vue3 Notes on setup ...
I saw this question in the SQL training question ...
I updated MySQL 8.0 today. The first problem: Nav...
There are always some problems when configuring n...
The search binary tree implementation in JavaScri...
This database query statement is one of 50 databa...
Vertical table Vertical table splitting means spl...
Preface: I encountered a requirement to extract s...
There are many tasks to be done in search engine o...
1. Disk partition: 2. fdisk partition If the disk...