html - 防止文本自动换行,最小宽度?

标签 html css

我刚刚开始使用 Web,我的首要任务之一是修复一些跨浏览器 UI 问题。在 Firefox 和 Internet Explorer 中,这段代码看起来不错:

<div id="readTypeBtns" style="text-align: left;margin-left: -30px">
    <label class="radio inline">
    <input value="First Read" id="firstread" type="radio">First Read</label>
    <label class="radio inline">
    <input value="Second Read" id="secondread" type="radio">Second End</label>
</div>

当我在 Chrome 中查看此内容时,文本 First Read 和 Second Read 自动换行,这使得单选按钮和文本不在同一行。我想知道为什么会这样。我玩了一下,我发现我可以为每个硬编码一些最小宽度,但这对我来说似乎不是一个“最佳”解决方案。有什么想法吗?提前致谢!

最佳答案

使用 CSS white-space属性:

label {
    white-space: nowrap;
}

关于html - 防止文本自动换行,最小宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15674369/

相关文章:

html - 将背景图像设置为正文时,固定宽度的 div 在 iPhone 中变小

javascript - 如何为 css 缩放属性设置动画

html - 如何防止连接波斯语字符?

jquery - 获得最高的div

html - 请推荐: static site generator without ruby

html - 如何使选择菜单的选项文本适合div

javascript - 如何修复应使用 CSS 突出显示选定区域的代码

javascript - Angular 4/Typescript - 如何使用 Typescript 编辑 HTML 文件

php - 如何去除 html 标签并从 php 中的变量中保留链接

底部页脚的 css 布局,动态 ajax 内容更改页面高度