Solved

How do I align picture on left and right next to it text in html using div

Posted on 2013-12-08
3
569 Views
Last Modified: 2013-12-10
I want to acheive like this in html using div or any good format. I cannot use css because it is a knockou js script file.

Image    Text1
              Text2
              Text3

The text will be exactly on the right of the image but not below the image. I tried this code but it is putting my text below the image

MY CODE

<table>

            <tbody data-bind='foreach: $root.materials.Rows'>
            
                  
                  
                  <div style="float:left;width:158px;text-align:left;">
                  <img width="56px" height="56px" data-bind="attr : {src: Picture().Url}" /></div>
            <div style="float:right;width:158px;text-align:right;">
                        
                        <p>      <a data-bind="attr: { href:'/material/Lists/pictures/DispForm.aspx?ID=' + ID()}, text:Title"></a></p>
            </div>
<div style="float:left;width:180px;text-align:left; ">
                              <span data-bind='text: Specialities_Title'></span>
      </div>
                        
                  <div style="float:left;width:180px;text-align:left; ">
                        
                              <span data-bind='text: Degree'></span>
                        </div>                        
                        <div style="float:left;width:180px;text-align:left; ">
                              <span data-bind='text: Street'></span>
                        </div>                        
                        <div style="float:left;width:180px;text-align:left; ">
                              <span data-bind='text: City'></span>&nbsp<span data-bind='text: State'>&nbsp</span><span data-bind='text: Zip'></span>
                        </div>                  
                  <div style="float:left;width:180px;text-align:left;">
                              <span data-bind='text: Phone'></span>
                                
                  </div>
                  
            </tbody>
      
      </table>
0
Comment
Question by:bujjigadu
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
duttcom earned 310 total points
ID: 39705412
You probably don't need the table and you have way too many divs there. Try something like this where there are only two divs - one with float:left to hold the image and the other one without float (and a fixed size) which will just sit next to the first div. You can add paragraph tags or other formatting to the spans within the second div -

<div style="float:left;width:158px;text-align:left;">
<img width="56px" height="56px" data-bind="attr : {src: Picture().Url}" />
</div>
<div style="width:158px;">

<a data-bind="attr: { href:'/material/Lists/pictures/DispForm.aspx?ID=' + ID()}, text:Title"></a>

<span data-bind='text: Specialities_Title'></span>

<span data-bind='text: Degree'></span>

<span data-bind='text: Street'></span>

<span data-bind='text: City'></span>&nbsp<span data-bind='text: State'>&nbsp</span><span data-bind='text: Zip'></span>
                       
 <span data-bind='text: Phone'></span>
                               
                  </div>
0
 

Author Comment

by:bujjigadu
ID: 39706261
It doesn't work. Still put the text under picture
0
 

Author Closing Comment

by:bujjigadu
ID: 39710088
not exact answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now