Home > Article > Web Front-end > What are the differences between negative vertical-align values and negative margin-bottom values?
What are the differences between negative values of vertical-align and negative values of margin-bottom? The following article will introduce to you the difference between negative values of vertical-align and negative values of margin-bottom. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Let’s first take a look at the values of vertical-align in W3C:
But it has a numerical value like this It’s rarely mentioned. Let’s look at this piece of code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .test_box { width: 45%; float: left; margin-right: 1%; background-color: #f0f3f9; } .mb-200 { margin-bottom: -200px; } .va-200 { vertical-align: -200px; } </style> </head> <body> <p class="test_box"> <img src="http://image.zhangxinxu.com/image/study/s/s128/mm1.jpg" class="mb-200" />张含韵 </p> <p class="test_box"> <img src="http://image.zhangxinxu.com/image/study/s/s128/mm1.jpg" class="va-200" />张含韵 </p> </body> </html>
Here I wrote two p’s. They all contain the same img. The box is completely separated from the text flow, and the size is entirely supported by the child elements. What is the display effect?
vertical-align will increase the height of the container, while negative margin-bottom values will decrease it!
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of What are the differences between negative vertical-align values and negative margin-bottom values?. For more information, please follow other related articles on the PHP Chinese website!