Hii friends,
I want to know that how block element can be centered with css...
Wooden Pen Drive | Promotional Power Bank
Printable View
Hii friends,
I want to know that how block element can be centered with css...
Wooden Pen Drive | Promotional Power Bank
There are three ways of centering a block with CSS as:-
Centering with margins
Centering with percentages
Centering with absolute sizes.
These are the multiple techniques for centering a block element, but techniques dependent upon the size set in percentages or in more absolute values.
but I just got it. Since I don't see a way to delete the topic, I'll reply to myself, in case someone else is stumped by this.
I just did a simple test in Codepen with a div and an image element inside. You can (horizontally) center the image within the div in either of these two ways:
1) div img {display:block; margin: auto;}
or
2) div {text-align: center;}
The difference is in the selector, whether you apply the style to the image or to the div. But both give the same result.
1) div img {display:block; margin: auto;}
or
2) div {text-align: center;}