开发者

Text in a table goes onto different line, instead of increasing size of table?

开发者 https://www.devze.com 2023-02-18 17:32 出处:网络
I am a complete novice at HTML as i decided to skip it and go straight to PHP. But i am getting a script to print long pieces of text and every time it is longer then the HTML table was set the width

I am a complete novice at HTML as i decided to skip it and go straight to PHP. But i am getting a script to print long pieces of text and every time it is longer then the HTML table was set the width just grows instead of it going onto a different line. How do i change this? Thanks :D

Heres my code:

<style type="text/css">
.style1 {
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
    background-image: url('file:///C:/wamp/www/style/images/banner.gif');
}
.style2 {
    font-size: small;
    color: #62D7D7;
}
.style3 {
    text-align: center;
}
.style4 {
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
    font-size: small;
    color: #0070B8;
}
.style5 {
    font-size: small;
}
</style>




    <table align="center" style="width: 28%; height: 100px">
        <tr>
            <td class="style1" colspan="2" style="height: 14px">&nbsp; JDiskwl1
            <strong>&nbsp;</strong><span class="style2">frank james</span></td>
        </tr>
        <tr>
            <td class="style3" style="width: 6px; height: 60px">Thumnail</td>
            <td class="style5" style="height: 60px"><?php print $example ?></td>
        </tr>
        <tr>
            <td class="style3" style="width: 6px">&nbsp;</td>
            <td clas开发者_开发技巧s="style4">Respond (244) Like (12)</td>
        </tr>
    </table>


Assuming something like this is what you're looking for:

Text in a table goes onto different line, instead of increasing size of table?

The following code does the trick:

<html>
        <head>
                <style type="text/css">
                        .style1 {
                                font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
                                background-image: url('file:///C:/wamp/www/style/images/banner.gif');
                        }
                        .style2 {
                                font-size: small;
                                color: #62D7D7;
                        }
                        .style3 {
                                text-align: center;
                        }
                        .style4 {
                                font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
                                font-size: small;
                                color: #0070B8;
                        }
                        .style5 {
                                font-size: small;
                        }
                </style>
        </head>
        <body>


                <table style="width: 700px; margin: auto;">
                        <tr>
                                <td class="style1" colspan="2" >JDiskwl1 <span class="style2">frank&nbsp;james</span></td>
                        </tr>
                        <tr>
                                <td class="style3">Thumnail</td>
                                <td class="style5">I am a complete novice at HTML as i decided to skip it and go straight to PHP. But i am getting a script to print long pieces of text and every time it is longer then the HTML table was set the width just grows instead of it going onto a different line. How do i change this? Thanks :D></td>
                        </tr>
                        <tr>
                                <td class="style3">&nbsp;</td>
                                <td class="style4">Respond (244) Like (12)</td>
                        </tr>
                </table>
        </body>
</html>


Try adding

word-break: break-all

to your table styles. See a demo here.

0

精彩评论

暂无评论...
验证码 换一张
取 消