I want to center a div with position fixed. And its width is specified as 300px and not in percentage.
<div class="mainCont">
  <div class="childCont">
</div>
childCont is div with fixed pos and width 300px. I want to make it as center.
I want to center a div with position fixed. And its width is specified as 300px and not in percentage.
<div class="mainCont">
  <div class="childCont">
</div>
childCont is div with fixed pos and width 300px. I want to make it as center.
Use following css:
.childCont {
    left: 50%;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
}
Use the following CSS to your 'childCont' class:
.childCont {
    position: fixed;
    width: 300px;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%,-50%, 0);
}
You can use top:50% and right: 50%