@ahmetkabacali
Posted
hi,
-Give it the attribute position:relative
according to which container you want it to be positioned and give position: absolute;
to the item you want to move. Your fault is you gave it to ".bg"
*editted code
.item1 {
position: relative;
}
.bg {
position: absolute;
top: 0;
right: 20%;
height: 100px;
z-index: -1;
}
-Note that the width/height do have to be specified absolutely, which uses sizing relative to the viewport.
*simple example;
#parent {
width: 500px; /*100vw*/
height: 500px; /*100vh*/
background-color: gray;
display: flex;
}
#child {
width: 50px;
height: 50px;
background-color: red;
margin: auto auto;
<div id="parent">
<div id="child"></div>
</div>
Happy Coding😉
Marked as helpful