简体   繁体   中英

CSS/HTML: element that is centered wont center right

If you check this:

http://jsfiddle.net/QbMmX/1/

Then you can see that the box(div element) is moving more at the left than the text. It doesnt get center like the text does. Why is this occuring and how can i fix this?

#recentStatus is centering as you're expecting as a result of its display: inline style.

So if you add display: inline-block to .userStatusComment , it'll center similarly to the other elements.

Take a look at this modified version of jsfiddle:

http://jsfiddle.net/QbMmX/4/

I have added a background-color to both the right and left elements to help you visualize the result and reason why the centering was not happening the way you wanted. This seems to work in chrome.

Hope this helps.

Bob

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM