Reputation: 311
I have div in HTML, there is i Picture and a piece of text. I have all this center through margin, but it is all in left. Why? HTML:
<div class="slozka">
<img src="http://randompics.net/gmig6jx/" alt="složka"></br>
{{object}}
</div>
CSS:
.slozka
{
width:125px;
padding:0px
}
.slozka > img
{
width: 100px;
height: 100px;
margin: 0 auto;
padding:0px;
}
.slozka:hover
{
border-style: outset;
}
Upvotes: 1
Views: 62
Reputation: 4514
You just need to provide "text-align: center;
" to ".slozka{...}
" class
Upvotes: 0
Reputation: 24703
You may need to center .slozka
also.
.slozka
{
width:125px;
padding:0px;
margin: 0 auto;
text-align: center;
}
Also if </br>
is supposed to be a line break then it is in correct, you need <br />
Upvotes: 0
Reputation: 943142
Auto margins centre block elements. That image is display: inline
(the default).
Set .slizka { text-align: center; }
instead (this centres inline content).
Upvotes: 4