I want to move div .container
down. I tried using (margin-top: 30px) is working but it moves down the border of (.container) down together with outline
of .all
. I want the border of .container
to be the only one that is moved down:
.all {
outline: 3px solid blue;
height: 100vh;
outline-offset: 5px;
position: relative;
}
.container {
border: 2px solid red;
height: 600px;
width: 335px;
margin-top: 30px;
}
<div class="all">
<div class="container">
</div>
</div>
3
Answers
either:
or:
To move only the border of the
.container
element down without affecting the outline of.all
, you can applypadding-top
to.all
.Using
transform
instead. For absolute distance you want,translate
is the good choice. For this situationtranform: translateY(*px)
is the way.Btw we can combine
position
withtop left bottom right
too.use
position: relative
at parent node to mark the spot to usingtop/left
.use
position: absolute
at the node you want to move andtop: 30px
to move it down 30px from parent node