Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have image and text side by side

Tags:

html

css

enter image description here

I'm trying to have the [as shown in picture] , facebook icon and text side by side. I cannot able to get that clearly.

My tried code

CSS

 .iconDetails {
 margin-left:2%;
float:left; 
height:40px;
width:40px; 
} 

.container2 {
    width:100%;
    height:auto;
    padding:1%;
}

HTML

<div class='container2'>
        <div>
            <img src='http://ecx.images-amazon.com/images/I/21-leKb-zsL._SL500_AA300_.png' class='iconDetails'>
        </div>  
    <div style='margin-left:60px;'>
    <h4>Facebook</h4>
    <div style="font-size:.6em">fine location, GPS, coarse location</div>
    <div style="float:right;font-size:.6em">0 mins ago</div>
    </div>
</div>

My JSFiddle

like image 876
Lonely Avatar asked Sep 02 '13 07:09

Lonely


People also ask

How do I display a picture and text in the same line?

Entire trick is to use float: left; CSS property on the img element and all the text will automatically wrap around that image. So if you want to align text and image in the same line in HTML like this... In short that is it.

How do I align text and an image in the same line in Word?

Hold down Shift and use the mouse or touchpad to select the objects that you want to align. Select Shape Format or Picture Format. Select Align. If you don't see Align on the Shape Format tab, select Arrange, and then choose Align.

How do I display images and text side by side in HTML table?

Choose Insert table: Then, use the toolbar icon again to add another column: You'll have two columns now: Add your content - Use the picture icon for an image and in the other column, add your text.


1 Answers

Your h4 has some crazy margin on it, so remove it

h4 {
    margin:0px;
}

http://jsfiddle.net/qMdfC/2/

edit:

http://jsfiddle.net/qMdfC/6/

for the 0 minutes text, added a float left to the first div, but personally i'd just combine them, although you may have reasons not to.

like image 144
MLeFevre Avatar answered Oct 18 '22 00:10

MLeFevre