mobile - 随着浏览器窗口缩小,标题不会溢出省略号

标签 mobile css overflow whitespace

http://jsbin.com/oqotew/edit#html,live

如果您在宽浏览器窗口中访问上面的链接,文本会出现在图像的右侧。如果缩小窗口,文本会跳到图像下方。

目标:我希望文本始终保持在图像的右侧,并在窗口太窄无法容纳文本时溢出“...”,而不是将其撞到图像下方。那可能吗?

我的 CSS 看起来像这样:

img { float: left; margin-right: 10px; }
.details { float: left; }
a { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color: #39C; font-size: 16px; text-decoration:none; }

HTML:

<img src="http://placehold.it/130x65" />
<div class="details">
  <a href="#">Kind of a long title for a url. This should overflow with ellipsis if the browser gets narrower.</a>
</div>

最佳答案

尝试从 .details 中移除 float

img { float: left; margin-right: 10px; }
a { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color: #39C;
font-size: 16px; text-decoration:none; }

已更新 demo

关于mobile - 随着浏览器窗口缩小,标题不会溢出省略号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11366641/

相关文章:

assembly - 想要在程序集中以空终止字符串,但出现段错误

HTML+CSS 高度/边距/边框/填充不相加

javascript - 在 jQuery Mobile 中更改页面时闪烁的 UI

html - 移动 Firefox 和 Chrome 无法识别@font-face

javascript - (React Native) 按下按钮时检索 JSON 文件中的下一个值

mobile - Google API OAuth 2.0 Titanium : Required parameter is missing: response_type

html - 为什么一个 div 正在移动到另一个?

css - Twitter Bootstrap 透明按钮

html - 带十字而不是箭头的进度光标

html - 是否可以将内容溢出到类似 iframe 的页面中?