How can I center a div inside a div?

Jason94

I'm trying to create a contact list but can't wrap my head around it. I want to vertically center the detailspanel:

.contactpanel .icon
{
    background: url('http://www.alter-net.info/Person.png');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: 14px 14px;
    position: absolute;
    left: 0;
    width: 60px;
    height: 60px;
}

.contactpanel .detailspanel
{
    margin-left: 65px;
}

It's on JSFiddle:

http://jsfiddle.net/hu6wq7km/

I want the details (name and email) to be centered vertically inside the panel, how can I accomplish that?

Linus

If the height is unknown you could use the "table trick" to vertically center your content.

Link to JSbin: http://jsfiddle.net/9xqdtbqu/

CSS:

.contactpanel
{
    display:table;
}

.contactpanel .icon
{
   display: table-cell;
   vertical-align: middle;      

}

.contactpanel .detailspanel
{
   display: table-cell;
   vertical-align: middle;    
} 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I center div, inside other div with bootstrap classes?

From Dev

How can I center data inside parent div?

From Dev

How can I center text inside a div element using CSS

From Dev

How can I center data inside parent div?

From Dev

How can I center horizontally a Grid-block inside of a div?

From Dev

How can I center a div inside another div, what is the simplest way?

From Dev

How can i center an inner div?

From Dev

How can I center vertically a div in bootstrap?

From Dev

How can i center an inner div?

From Dev

How can I center my ul li list inside my div?

From Dev

How to center elements inside a div?

From Dev

How to center a picture inside a div?

From Dev

How to center a table inside of a div?

From Dev

How To Center Inside Bootstrap Div

From Dev

Center <div> inside a <div>

From Dev

How to center the DIV inside another parent DIV

From Dev

How to center a div inside another div

From Dev

how to center (V,H) div inside div

From Dev

How To Properly Center A Div Inside A Div

From Dev

How do I center the elements inside a div from the below code

From Dev

How can I make a DIV inside a DIV use 90% of the width?

From Dev

How can I make a DIV inside a DIV use 90% of the width?

From Dev

How can I set margin for div inside column div in bootstrap

From Dev

How can I activate the hover of a div inside of other div?

From Dev

Can't center an element inside div

From Dev

can not center input fields inside div

From Dev

can not center input fields inside div

From Dev

Can't vertically center a paragraph inside a div

From Dev

How do I center a div in another div?