employer cover photo
employer logo
employer logo

Tata Consultancy Services

Part of Tata Group

Engaged Employer

Tata Consultancy Services Interview Question

Position in css

Interview Answer

Anonymous

Mar 9, 2021

position property allows us to set the position/coordinates of element ex: top, left, right , bottom z-index etc will create no effect if we dont change the default value of position css property . There are mainly 5 values we can assign to position css property: 1) Static - as i mentioned above by default position is static and no effect on element position even when you set top: 20px etc. 2)Relative - Element's new position will be relative to its original position. 3) Absolute - Element new position will be positioned to its 1st non-static positioned parent. 4) Fixed - element new position will be positioned relative to tag and not relative to any other parents. 5) Sticky - it is a mix of position relative and fixed.