Not understanding the behaviour of position:static?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
AI Thread Summary
The discussion centers on the behavior of CSS positioning, particularly the use of "position: static" in responsive design. The key point is that "position: static" is the default positioning for elements, meaning they stack vertically and do not respond to top, bottom, left, or right values. In the provided example, both the ".dropdown" and ".subdropdown" elements initially have "position: absolute," allowing the subdropdown to appear to the right due to "left: 100%." However, when the display width is reduced to 500px or less, the media query resets the position to "static," causing the elements to stack vertically and rendering the "left: 100%" ineffective. Removing "position: static" from the media query would lead to layout issues on mobile devices, highlighting the importance of understanding how CSS positioning interacts with media queries in responsive design.
shivajikobardan
Messages
637
Reaction score
54
TL;DR Summary
position:static in dropdown and subdropdown.


I'm learning responsive design. (Make width <500px and see)

I'm talking about this line:

CSS:
.dropdown,
  .subdropdown {

    position: static;

    width: 100vw;

}



This is the behaviour I'm getting with and without position:static. But I fail to understand why? All information that I've about position:static is that it doesn't accept Top,Bottom,Left,Right values.
 
Technology news on Phys.org
position:static places the document in default. the default is one at the top of other. this sounds reasonable to me.
 
position: static is the default, there is no need to set position: static unless it is to override a different setting of position with a lower priority.

Which is exactly what is happening in the example shown, in the default CSS you are setting position: absolute on both .dropdown and .subdropdown elements, and you are setting left: 100% on subdropdown so it hangs off to the right. However in a media query which takes effect when the display width is <= 500px you are overriding this to reset position to its default value of static so now left:100% doesn't do anything and everything stacks vertically. If you remove position: static from the media query the subdropdown breaks on mobile.
 
pbuk said:
position: static is the default, there is no need to set position: static unless it is to override a different setting of position with a lower priority.

Which is exactly what is happening in the example shown, in the default CSS you are setting position: absolute on both .dropdown and .subdropdown elements, and you are setting left: 100% on subdropdown so it hangs off to the right. However in a media query which takes effect when the display width is <= 500px you are overriding this to reset position to its default value of static so now left:100% doesn't do anything and everything stacks vertically. If you remove position: static from the media query the subdropdown breaks on mobile.
thank you.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top