I am using Bootstrap and I want to have the top-right side of the red background always sit to the top right corner of the blue section in the visible section regardless of how window resized as it is responsive.
Red should be position fixed as it should not be moved by scrolling but always should sit on the right-top side of the visible blue background section.
as the picture it should be like this :
If I scroll ( I did it with windows paint now)
Please check the link or see the below codes :
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.left {
background-color: blue;
width: 100%;
height: 4000px;
}
.right {
background-color: red;
width: 100%;
position: fixed;
right: 18%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-11 left">left
</div>
<div class="col-1 right">right
</div>
</div>
</div>