3

Morning all,

I'm having an alignment issue.

I am using a MYSQL array to create a sports profile page.

I want it to display the image, then to the right, show their name, position and number below each other.

Then i want it to dynamically display 3 or 4 of these next to each other before swapping down to the next line.

I have managed to get it to work with just the pictures, not with the text in between. they all just show on new lines currently.

<style>
   #container .profile{
               display: inline-block;
               vertical-align:top;
                      }
</style>
<div class="profile">
<img src="wp-content/uploads/profile/jh7.jpg" alt="" /><br />
<h3 class="widget-title">Player 1</h3>
<p>Defence</br>#7</br></br>
<img src="wp-content/uploads/profile/dw21.jpg" alt="" /><br />
<h3 class="widget-title">Player 2</h3>
<p>Defence</br>#21</br></br>
<img src="wp-content/uploads/profile/pn22.jpg" alt="" /><br /> 
<h3 class="widget-title">Player 3</h3>
<p>Defence</br>#22</br></br>
</div>
                </div><!-- .entry-content -->


</div>

Thanks guys

2
  • 2
    This is a CSS question. Please replace the PHP with the HTML that is outputted, and then remove the PHP and MySQL tags. Commented Jan 1, 2015 at 12:06
  • @SverriM.Olsen Although, to be fair, the OP might not have known that! Commented Jan 1, 2015 at 12:06

4 Answers 4

1

You can use float left for the image:

<style>
    .profile img{
        float: left;
          margin-right: 5px;
    }    
  </style>

Checkout this DEMO: http://jsbin.com/jigotamamu/1/

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for that, that's almost cracked it.
I now have the text next to the pictures as desired. Can I get it so that there are 3 or 4 of these in a line rather than 1 on each row? Like columns on the page?
Sure, make them in a list and style it horizontally! i.e from your initial code, replace <br /> with <ul><li>Number</li><li>another</li>...</ul>
I mean an inclusive set of image and the associated text, then another set etc, wouldn't listing horizontally just make the text go side by side?
Checkout this demo and place any html tags you want: jsbin.com/jigotamamu/2/edit
|
1

Quick example : float the images and clear the float with a block element having a clear: both property :

http://jsfiddle.net/L8jtwkw1/2/

You can wrap each profile in a container and use inline block to list them horizontally then.

4 Comments

Well, that doesn't exactly put three to a row
Yeah, I think the OP's issue is about css formatting in general - but, getting three in a row in particular.
I need the text next to the picture, then the other pictures with text, to line horizontally
Edited my answer with an updated link to reflect what you want :)
1

It still didn't do exactly what I was after, However I managed to sort it by putting a column in:

<style> 
.profile img{ 
      float: left; 
      margin-right: 10px; 
      margin-top: 2px; } 
.profile h3 { display: inline-block; } 
.profile pos{ } 
.column-left{ float: left; width: 33%; } 
</style> 

Comments

0

I think that thie problem is in <h3> tag - you need either replace it with <span> or override styles for it.

For example:

echo '<img src="wp-content/uploads/profile/'.$row['Id'].'.jpg" alt="" />',
   '<span class="widget-title">'.$row['FirstName'].' '.$row['Surname'].'</span>',
    $row['PositionLong'].'</br>',
   '#'.$row['Number'].'</br>';

If you show the css styles for widget-title, we can help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.