cup_of cup_of - 1 month ago 4
CSS Question

How to "cancel" out left/right for absolutely positioned element?

I have a div that is positioned absolutely and I gave it a


For desktop it is necessary to have the
position of 100px.

But for tablet I want to push it all the way to the right.

To achieve this I tried doing
right: 0
, but since
left: 100px
is already defined in the CSS, the
right: 0
does not push it all the way to the right as intended.

Then I tried doing
left: 0
in tablet to cancel out the effect that it has but that didn't work either.

Is there a way to cancel out the
position? Something like
left: none
(I know that does not work but it's the only way I am able to explain this.)

Desktop CSS:

.mydiv {
positon: absolute;
left: 100px;

Tablet CSS:

@media (max-width:768px){
.mydiv {
left: 0;
right: 0;

I could do something like
right: 400px
to get it to the position that I want but I am just curious if there is a way where I can use
right: 0
so I know for sure that it is pushed totally to the right.



To reset the left property use

left: auto;

You can use CSS reference to get initial values of CSS properties. For example here is the reference for the left property: