Home  >  Article  >  Web Front-end  >  Why can’t CSS move after adding top?

Why can’t CSS move after adding top?

藏色散人
藏色散人Original
2021-03-22 11:26:261868browse

The reason why top cannot be moved after adding top to css is because the value of the "position" attribute is "static", so setting the "top" attribute will not have any effect. The solution is to ensure that the value of the "position" attribute is "Absolute" or "relative" will do.

Why can’t CSS move after adding top?

The operating environment of this article: Windows 7 system, CSS3 version, DELL G3 computer

The top attribute in css does not work?

In CSS positioning, sometimes when using the top attribute for offset, it is found that the top attribute does not work. Why is this? How to deal with it? The following article will introduce it to you, I hope it will be helpful to you.

First let’s learn about some top attributes:

The top attribute in css specifies the top edge of the element. This property defines the offset between the top margin boundary of a positioned element and the top boundary of its containing block.

Why does the top attribute not work? How to solve it?

The top attribute refers to the distance to the left or top of the nearest parent element whose position attribute is relative or absolute, so when the value of the "position" attribute is "static", then set The "top" attribute will have no effect.

Solution to the problem that the top attribute does not work: Make sure the value of the position attribute is absolute or relative.

【Recommended learning: css video tutorial

The above is the detailed content of Why can’t CSS move after adding top?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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