Yes, there are places where margin 0 auto is the best choice, and there are places where negative margins are the best choice. If you like this tip, I will be happy to get your LIKE. That's it we center the element horizontal! This CSS will center the element left side to the center of the window.īut we want the modal box to centered window according to the middle of the element.Īnd now comes the trick, because we have two wrapper to the popup, we can manipulate the inside div and will tell him to go left -50% relative, and because it is in a container he will move only half of is size to the left. The trick is quite simple, instead of using only one wrapper element, use two elements. In this tip, I will show you how to center modal box without using JavaScript. A lot of people try to center element like modal box in absolute/fixed position in the center of the page via only CSS and fail, then they try to do it with JS(second mistake).
0 Comments
Leave a Reply. |