css中的换行符
Introduction:
介绍:
Dealing with various items in CSS sometimes pose very different problems. The problem could be anything, it could be related to positioning, arrangement, and whatnot, therefore all such kinds of problems require smart and creative solutions. Solutions are considered best if they do not increase the line of codes instead optimize the entire code in a much more efficient manner simultaneously resolving the issue. Such solutions are known to be good solutions but not everyone can come up with solutions, although one should keep trying. However, even if you don't, these articles are always out there for your convenience in just one click away. Now, let us take this discussion further and talk about the above-mentioned topic.
在CSS中处理各种项目有时会带来非常不同的问题。 问题可能是任何东西,都可能与定位,布置等有关,因此,所有这类问题都需要明智且具有创造性的解决方案。 如果解决方案不增加代码行,而是以更有效的方式优化整个代码,同时解决问题,则被认为是最佳解决方案。 众所周知,这样的解决方案是很好的解决方案,但并非所有人都能提出解决方案,尽管应该不断尝试。 但是,即使您不知道,这些文章也总是会出现在这里,以方便您单击一下。 现在,让我们进一步讨论,并讨论上述主题。
How can we prevent line breaks in the list of items using CSS? Well, many developers come across this question at one point in their developing period. The problem might seem tricky and confusing but the solution is very easy to understand and you will be able to learn it in no time. As said earlier, dealing with a list of items can prove to be tricky, therefore such types of problems tend to occur. Besides, it would be very good if we can prevent line breaks in a list of items and that too with the help of CSS. So let us get right on to the solution and get it over with.
如何使用CSS防止项目列表中出现换行符? 好吧,许多开发人员在开发阶段就曾遇到过这个问题。 该问题看似棘手且令人困惑,但解决方案非常易于理解,您将能够立即学习。 如前所述,处理项目列表可能会很棘手,因此这类问题容易发生。 此外,如果我们可以防止在项目列表中出现换行符,并且在CSS的帮助下也可以防止换行符,那将是非常好的。 因此,让我们继续研究解决方案并付诸实践。
Solution:
解:
The property in play here, to tackle this problem would be display:inline-block property. This property is used to display any element in the inline-level block container. This property plays a role of converting the block of elements into an inline element. You may use height and width property to set or fix an inline element. Therefore, this display property plays a major role in preventing the line break in a list of items using CSS.
为了解决这个问题,此处显示的属性将是display:inline-block属性。 此属性用于显示内联级块容器中的任何元素。 该属性起着将元素块转换为嵌入式元素的作用。 您可以使用height和width属性设置或修复内联元素。 因此,此显示属性在防止使用CSS的项目列表中出现换行中起着主要作用。
Syntax:
句法:
element {
display:inline-block;
}
Example:
例:
<!DOCTYPE html>
<html>
<head>
<style>
li {
display: inline-block;
text-decoration: underline;
}
body {
width: 70%;
}
</style>
</head>
<body>
<h2>Prevent line breaks in list</h2>
<b>Languages on IncludeHelp:</b>
<ul>
<li>C++</li>
<li>Java </li>
<li>Python</li>
<li>Scala</li>
<li>Android</li>
</ul>
</body>
</html>
Output
输出量
In the above example, there is no new line for each list.
在上面的示例中,每个列表没有新行。
Ending note:
结束语:
So, as you saw by making use of display property you can prevent the line breaks in a list of items using CSS. Pretty easy solution right? Told you! All you gotta do is make use of one single property and voila, problem solved. This way line breaks won’t bother you ever again whenever you are creating a certain list of items and your code doesn’t get altered much. So what are you waiting for now? You have the solution, so go ahead and try this out this method.
因此,如您所见,通过使用display属性,您可以使用CSS防止项目列表中的换行 。 很简单的解决方案吧? 告诉过你了! 您所要做的就是利用单个属性,瞧,问题解决了。 这样,无论何时创建项目的特定列表,换行符都不会再打扰您,并且您的代码不会发生太大变化。 那你现在还在等什么呢? 您已找到解决方案,所以继续尝试此方法。
翻译自: https://www.includehelp.com/code-snippets/how-to-prevent-line-breaks-in-the-list-of-items-using-css.aspx
css中的换行符