Solved

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

Posted on 2013-12-08
3
609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

691 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