How to Vertically align all elements Inside a div?

Hi there

This is my jsfiddle

I want to vertically placed inside a div all HTML elements inside a div How can I do this?

McAfee SiteAdvisor is warning me not to visit your site.

    .vcontainer {
min-height: 10em;
display: table-cell;
}

.vcontainer img {
vertical-align: middle;
}

I don’t need Image and text like this

I need them something like this

This is Image

This is Another Text

This is Another Text-2

One after another

like this…?

 .vcontainer {
display: table-cell;
min-height: 10em;
border:1px solid #000;
}

.vcontainer img {
vertical-align: middle;
}
label{
display:block;
}

The display setup is wrong. You are applying setting to the container that should be applied to the children of the container.

.vcontainer {
   min-height: 10em;
   display: table;
}
.vcontainer img, .vcontainer label {
    display: table-cell;
    vertical-align: middle;
}

The container should be displayed as table and the children as table cell, with the alignment set.

Although your code is working fine

but I want not only label to be diaplyed as vertcially but all elements irrespective of element type

it can be anchor,image,strong and others to

Then apply a class to the elements, and select that class in your css.

Thanks SamA74

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.