Reputation: 4642
I am a newbie in front-end development, so please bear with me if the question is too basic. What I am trying to achieve is very similar to the following problem:
How do I move the search bar on SO's website to the left without affecting the other elements? I can't use the margin-left property since that would move the other elements as well. Is there any way to achieve this? Thanks!
Upvotes: 4
Views: 14784
Reputation: 79
Depends on your situation: I would say try adding “position: relative;” & “right: 10px” for e.g.
I hope this helps!
Upvotes: 1
Reputation: 327
You can do this by using the transform
property.
Use transform: translateX(n px/vh/vw/em)
This will not affect other elements.
There is another way to do this:
top
and left
properties to modify the position.Note: In both cases only the rendering of graphics on the screen is shifted. The element will be present in its original position.
Upvotes: 1
Reputation: 1303
You can use margin-left negative + margin-right positive;
margin-left: -10px;
margin-right: 10px;
Upvotes: 10