Position center of div tag, which width is unknown advanced
问题 I have div with no fixed with. I want this div position in the center of screen. I know how to make this with jquery, but with pure css, I did not find any solution. How do you make this happen with pure css? 回答1: Assuming you want to shrink-wrap the contents of the div (otherwise centring it is a pointless exercise as its width will be the width of the container): Set display: inline-block; on the div to make it shrink-wrap Set text-align: center; on the div's parent element to centre the