In the actual work we often encounter the need to set the horizontal center of the scene, for example, in order to beautiful, the title of the article is generally horizontal center display.
Here we score two things: the inline element or the block element, inside the block element is divided into a fixed-width block element, as well as an indefinite wide block element. Today, let's look at how inline elements are horizontally centered.
If the element is set as a text, picture, and other inline elements, the horizontal center is implemented by setting the parent element text-align:center . (Parent and child elements: in the following HTML code, the div is the parent element of the text that I want to be centered horizontally in the parent container.) The text is the sub-element of the DIV) and the following code:
HTML code:
<body> <div class= "Txtcenter" > I want to center the display horizontally in the parent container. </div></body>
CSS code:
<style> . txtcenter{ text-align:center; } </style>
Center horizontal setting-inline elements