Home >Web Front-end >Front-end Q&A >Why can't CSS move after adding top?
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.
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!