Home > Web Front-end > HTML Tutorial > In CCS, is margin-bottom really invalid? _html/css_WEB-ITnose

In CCS, is margin-bottom really invalid? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:54:45
Original
1464 people have browsed it



For example, I want the words in the picture above to be displayed at the bottom, and sometimes the title is two lines, so setting margin-top certainly cannot solve the problem at once.

is similar to the following part:

<div>   <p>巴萨憾负塞尔塔,梅西哭晕在厕所。</p></div>
Copy after login


I make the margin-bottom: 0 of the outer div invalid.
The web page is laid out from top to bottom. Is this the reason why margin-bottom is invalid?
Is there any solution to make margin-bottom effective? (Except for position:absolute methods). If margin-bottom is really invalid, doesn't the existence of this attribute have only theoretical significance?


Reply to discussion (solution)

You misunderstood the meaning of this attribute. It refers to the bottom margin of the element you set. But it does not mean that it is at the bottom of the parent element, nor does it mean that its child elements will be displayed at the bottom of it. In the case like you said, it will only work if you use absolute positioning and set bottom:0.

margin-bottom works. I have used it many times.

You misunderstood the meaning of this attribute. It refers to the bottom margin of the element you set. But it does not mean that it is at the bottom of the parent element, nor does it mean that its child elements will be displayed at the bottom of it. In this case like you said, it will only work if you use absolute positioning and set bottom:0.


I have a question:
If there are no other sibling elements below the target element, why does margin-bottom:0 not mean that it is at the bottom of the parent element?
What does margin-bottom:0 mean?

It doesn’t mean, for example: you have two boxes to be placed from top to bottom. If you set margin-bottom:10px for the first box, then the second box will be farther away from the first box. 10px, if set to 0, it will be next to the first one (of course the second margin-top is also set to 0), margin-bottom is to set the interval between elements of the same level, not to set it in the parent position within the element.

Is it valid?

No, for example: you have two boxes to be placed from top to bottom. If margin-bottom is set for the first box :10px, then the second box will be 10px away from the first box. If it is set to 0, it will be next to the first one (of course when the margin-top of the second one is also set to 0), margin-bottom is Setting the spacing between sibling elements does not set its position within the parent element.


Yes, I understand when you say that. I confused the concept, thank you :)

It works, right?


Yes, Valid, I confused the concept~
source:php.cn
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