javascript - 当 inline-block 内容很长时如何防止 inline-block 换行
问题描述
当inline-block的红色文字较短时,正常显示。但是当inline-block的红色文字超过屏幕长度或内容过长时,红色文字会与其他文字换行显示。我想要的结果是当红色文字太长时,不需要换行。
<html>
<head>
</head>
<body>
<p>
<span>green and</span>
<span style='color:red; display:inline-block;vertical-align:top'>blue, green and blue Pink,purple, <span style="border-top:1px solid blue;red:red;display:block">Text annotation</span> </span> orange, black and white, Pink,purple, orange, black and white, stand up, sit down, turn around. Pink,purple, orange, black and white.3. BingoThere was a farmer had a dog, and bingo was h
<span>day friday Saturdaysunday monday tuesday wednesday thursday friday Saturday6. Little pigOink oink little pig Oink oink oink little pig Oink oink little pig Oink oink oink little pig7. I ‘m hungryI'm a little hungry,I'm hungry.Have som</span>
</p>
</body>
</html>
解决方案
如果我正确理解了这个问题,这就是您所要求的,请将您的文本包装在<p>
标签内,并且不会分开
.long-text {
color : red;
}
<p class="container">
green and
<span class="long-text">blue, green and blue Pink,purple, orange, black and white, Pink,purple, orange, black and white, stand up, sit down, turn around. Pink,purple, orange, black and white.3. BingoThere was a farmer had a dog, and bingo was h</span>
day friday Saturdaysunday monday tuesday wednesday thursday friday Saturday6. Little pigOink oink little pig Oink oink oink little pig Oink oink little pig Oink oink oink little pig7. I ‘m hungryI'm a little hungry,I'm hungry.Have som
</p>
推荐阅读
- php - 如何链接到页面的特定部分 HTML PHP
- c# - 当后端代码中的简单键值变量工作相同时,为什么要使用 redis 作为缓存层?
- google-apps-script - Google Slides Apps 脚本检索页面中的形状
- python-3.x - 在 KNeighborsClassifier 中使用自定义指标时,我不断收到“TypeError:只有整数标量数组可以转换为标量索引”
- java - JavaFX - 在使用选项卡时将 GUI 拆分为单独的类
- jquery - 通过函数调整电子窗口大小
- scheme - 匹配方案中的括号
- android - 当我使用 adb 显示 /sys/kernel/debug/tracing/available_filter_functions 时没有这样的设备
- python - 初始化以迭代抽象pyomo模型中的集合?
- angular-cli - 运行 ng serve -o 时出现错误