How to Centre Elements With CSS:-
- Centring a text
- Centring a block
- Centring a image
How to Center a Text Using CSS:-
p.center { text-align: center; }Then any paragraph written with class "center" will be centered horizontally.
<p class="center">This text is centered.</p>
How To Center a Block With CSS:-
div.center { margin-left: auto; margin-right: auto; width: 8em; }And the corresponding HTML code will look like this.
<div class="center">This entire block is centered, but the text inside it is left aligned.</div>
How to Center Images With CSS:-
Images are a little trickier. While most of the browser uses the same text-align property, but it is not a good technique. So lets center a image.img.center {display: block; margin-left: auto; margin-right: auto;}
And the HTML code will be.<img src="blwebcam-sample.jpg" alt="Suni" class="center" />
If you enjoyed this article then don't forget to subscribe it for latest updates.
More article from the same author Add Meta Description To Each Post Individually, How to Customize Blogger Comment Form.
Aucun commentaire:
Enregistrer un commentaire