I am currently trying to get a div to center in the middle of my page. I get it centering in the middle but I am having a problem when I resize the page. When I make the window as small in width as I can, the div goes off the left of the page. Here is a jsfiddle representing what I have:
https://jsfiddle.net/ghsxnsqy/
Here is some css:
.wrapper{
top: 50%;
left: 50%;
width:200px;
height:60px;
margin-top: -30px; /*set to a negative number 1/2 of your height*/
margin-left: -100px; /*set to a negative number 1/2 of your width*/
border: 1px solid #ccc;
position:fixed;
}
Now if you look at that and resize the window to make it as small as you can in width, you can see the div going off to the left. How do I make it stop at the edge of the page? I can't find a way without using margin auto. Any suggestions?