Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keeping everything in one line in div

Tags:

css

so my problem is like this:

I have a div, and in the div I have an img and then a string next to the image, the height is at 25, the width is at 128, and its align to center.

its just a username and a little icon next to their name. it works fine up until the user has a really long name in which case it will put the string onto a new line, which is definitely not what I want.

I would like it to just over flow and hide the rest of the name if it is too long. is there anyway I can do this?

I had overflow hidden as well as max-height and max-width. I tried using a span as well as display:inline but it keeps pushing it to a new line. I need to keep the alignment centered.

any help?

cant seem to find any information. I tried putting it in a table as well but to no avail.

here's the code:

<a href="#" class="tab2">        
    <table  align="center">            
        <tr>                
            <td valign="bottom"  id="contactLink1">    
                <div align="center" class="funtion_user_imageloc_box">
                    <?php if($memimglevelROW['imageloc']!=''){
                        if ($memimglevelROW['imageloc']=="black1.png"){?>
                            <img src="levelimage/<?php echo $memimglevelROW['imageloc'];?>"  alt="" width="30.5" height="16" align="center" class="funtion_user_img1" />&nbsp;    
                        <?php } else {?>
                            <img src="levelimage/<?php echo $memimglevelROW['imageloc'];?>" alt="" width="18" height="18" align="center" class="funtion_user_img2" />&nbsp;    
                        <?php }            
                    }
                    echo $username;?>
                </div>
            </td>        
        </tr>    
    </table>
</a>
like image 513
chris Avatar asked Nov 29 '22 04:11

chris


1 Answers

Welcome to the community!

  • Please try not to post a wall of text, as it makes reading your question difficult.
  • The preview of what you're typing is below the "Ask a Question" textbox.
  • Thanks for providing code!

You should try white-space: nowrap; as that will probably fix your problem.

Also, don't ever use tables for non-tabular data. It's not 1995 anymore, CSS can do anything a table can do.

like image 136
zzzzBov Avatar answered Dec 14 '22 23:12

zzzzBov