What are the differences between negative vertical-align values ​​and negative margin-bottom values?

青灯夜游
Release: 2020-11-06 18:00:47
forward
2395 people have browsed it

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.

What are the differences between negative vertical-align values ​​and negative margin-bottom values?

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>
Copy after login

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!

Related labels:
css
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!