html - 如何通过CSS将长文本元素保持在同一行?

标签 html css wordpress tag-cloud

我不是 css/html 专家,所以如果我不能正确解释问题,我很抱歉。

我有 2 个不同主题的 Wordpress 网站,我使用相同的小部件让它们显示标签。在第一个站点中,我们将其命名为 A,标签在同一行中紧随其后,即使标签必须被打断。在第二个站点B中,标签也是一个接一个,但如果一个标签的所有单词不能在同一行,则该标签将转到下一行。

更新:我在B中得到的是这样的:

first tag

very large second tag

但是在 A 我得到了这个:

first tag very large

second tag

这些标签是不同的元素,每个元素由a和span组成。

这会在我不喜欢的标签云中形成白色间隙。我试图通过 firefox 检查两个主题 css 并比较它们以确定要做什么,但找不到原因。我通过 firefox 检查元素在 B 中对 A 做了任何改变,但它没有用。

我将 firefox 为元素 div#tag-groups-cloud-tabs... 提供的所有 css 代码放在下面的两个站点中:

对于站点 A:

inline 139:
*::-moz-selection {
    background: none repeat scroll 0% 0% rgb(73, 138, 184);
}

style.css 137:
*::-moz-selection {
    background: none repeat scroll 0% 0% rgb(73, 138, 184);
    color: rgb(255, 255, 255);
}

inline:
element {
}

style.css 40:
*, html, body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, label, fieldset, input, p, blockquote, th, td {
    margin: 0px;
    padding: 0px;
    outline: 0px none;
    vertical-align: baseline;
    background: none repeat scroll 0% 0% transparent;
}

style.css 104:
* {
    outline: medium none;
}

style.css 197:
body {
    font: 13px/20px tahoma,'PT Sans',Arial,Helvetica,sans-serif;
    color: rgb(67, 67, 67);
}

对于站点 B:

style.css 470:
*::-moz-selection {
    background: none repeat scroll 0% 0% rgb(36, 137, 13);
    color: rgb(255, 255, 255);
    text-shadow: none;
}

style.css 758:
.footer-sidebar:after, .hentry:after, .slider-direction-nav:after, .contributor-info:after, .search-box:after, [class*="content"]:after, [class*="site"]:after {
    clear: both;
}

style.css 740:
.footer-sidebar:before, .footer-sidebar:after, .hentry:before, .hentry:after, .slider-direction-nav:before, .slider-direction-nav:after, .contributor-info:before, .contributor-info:after, .search-box:before, .search-box:after, [class*="content"]:before, [class*="content"]:after, [class*="site"]:before, [class*="site"]:after {
    content: "";
    display: table;
}

inline:
element {
}

rtl.css 34:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    border: 0px none;
    font-family: Tahoma;
    font-size: 100%;
    font-style: inherit;
    font-weight: inherit;
    margin: 0px;
    outline: 0px none;
    padding: 0px;
    vertical-align: baseline;
}

style.css 64:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    border: 0px none;
    font-family: inherit;
    font-size: 100%;
    font-style: inherit;
    font-weight: inherit;
    margin: 0px;
    outline: 0px none;
    padding: 0px;
    vertical-align: baseline;
}

style.css 2073:
.widget {
    font-size: 14px;
    -moz-hyphens: auto;
    line-height: 1.28571;
    word-wrap: break-word;
}

style.css 2055:
.content-sidebar {
    color: rgb(118, 118, 118);
}

rtl.css 121:
body, button, input, select, textarea {
    color: rgb(43, 43, 43);
    font-family: Tahoma;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

rtl.css 101:
body {
    direction: rtl;
}

style.css 102:
body, button, input, select, textarea {
    color: rgb(43, 43, 43);
    font-family: Lato,sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

最佳答案

对于一行语句使用white-space:nowrap;

see demo here

关于html - 如何通过CSS将长文本元素保持在同一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948530/

相关文章:

javascript - 如何启用 Bootstrap 向导最后一个按钮

javascript - 将内容/文本置于绝对 div 绝对中心;从中心变换

javascript - 当第一个函数完成 W/O 回调参数时执行第二个函数

html - 带有 "display: table"正文元素的 Bootstrap 响应表

php - WooCommerce 不会在发送给客户的电子邮件中显示自定义费用

javascript - 将图标/图像正确放置在 SVG 形状上?

javascript - 在 Canvas 中使用 ctx.scale() 方法时,调整大小和旋转在 fabricjs 中不起作用?

javascript - 如何添加带有空白导航标签的 WordPress 菜单项?

php - 如何在wordpress模板中使用自己的php变量?

html - CSS::child 设置为在父鼠标悬停时更改颜色,但在鼠标悬停时也会更改