How to vertically align a DIV next to an image?

前端 未结 3 2080
栀梦
栀梦 2021-01-04 07:34

I have the following html code:

\"\"
3条回答
  •  难免孤独
    2021-01-04 08:17

    try this

    #personalInfo{
       float: left;
       margin-top: 5%; 
       margin-left: 2%;
       font-size: 1.3em;
    }
    img{float:left;border:1px solid #333}
    #details{float:left;padding:10px 0 10px 0}
    

    working example: http://jsfiddle.net/bingjie2680/DSmKu/

    the idea is to float left both the image and details. by doing so two elements will have the same height. and then you can make the detail div padding top and bottom some space.

提交回复
热议问题