简体   繁体   English

表格中的文字会进入不同的行,而不是增加表格的大小?

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

I am a complete novice at HTML as i decided to skip it and go straight to PHP. 我是HTML的新手,因为我决定跳过它并直接进入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. 但是我得到一个脚本来打印长文本,每次更长时间,然后HTML表设置宽度只是增长而不是它进入不同的行。 How do i change this? 我该如何改变? Thanks :D 感谢: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 class="style4">Respond (244) Like (12)</td>
        </tr>
    </table>

Try adding 尝试添加

word-break: break-all

to your table styles. 你的桌子风格。 See a demo here. 在这里看一个演示。

Assuming something like this is what you're looking for: 假设你正在寻找这样的东西: 由Firefox 4呈现 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM