Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

html - How can I force two elements to always stay on the same line in a <td>

The code is pretty simple:

<table id="tabel_user" style="width: 100%; border: 0; background-color: white;" cellpadding="0" cellspacing="0">
<tr>
    <td style="border: 0; padding: 0; padding-left: 5px;">
        <label for="abcd"><input class="check_useri" id="abcd" name="abcd" type="checkbox" /> abcd </label>
    </td>
</tr>
</table> 

They stay neatly on the same line unless the text in the label gets really long and the table needs to stretch to accomodate it, then the text sometimes gets forced below the checkbox. How can I stop it from doing that?

question from:https://stackoverflow.com/questions/10008395/how-can-i-force-two-elements-to-always-stay-on-the-same-line-in-a-td

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can force inline elements to stay on the same line using the CSS property white-space:

<td style="white-space:nowrap;">
  this content will not be wrapped
</td>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...