Center Position Fixed Horizontally
I want to dynamically append to the end of the body a fixed-positioned to the bottom box that has 1000px width and is centered horizontally. When I create it with percentage width
Solution 1:
Try this also:
div{
position: fixed;
bottom: 0;
width: 1000px;
left: 50%;
transform:translateX(-50%);
height: 100px;
background-color: green;
}
Solution 2:
body:after {
content:"";
width: 1000px;
height: 100px;
position: fixed;
left: 50%;
bottom:0;
margin-left: -500px;
background-color:green;
}
Solution 3:
Try this:
div{
position: fixed;
bottom: 0;
width: 1000px;
left: 50%;
margin-left: -500px;
height: 100px;
background-color: green;
}
<div></div>
Solution 4:
Try CSS3, to avoid giving calculated values in pixel for your margins.
left:50%;
transform: translateX(-50%);
Here's a demo: https://jsbin.com/zejutisabo/edit?html,css,output
Post a Comment for "Center Position Fixed Horizontally"