简体   繁体   English

为什么这个 tetx 没有在 x 轴上溢出,即使我有一个固定的宽度和<p tag is set to display: block?< div></p><div id="text_translate"><p> 我需要文本在 X 轴上溢出只是为了重现我在更大项目中遇到的一些问题。 我留下一个简单的片段,所以你可以告诉我我在哪里做错了。 谢谢! </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> .article { background-color: rgb(236, 161, 161); width: 20em; }.article p { display: block; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;article class="article"&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis deleniti iure quidem distinctio officia voluptates similique molestiae culpa? Perferendis, velit maiores nobis maxime aut facere eaque quis voluptas accusamus commodi.&lt;/p&gt; &lt;/article&gt;</pre></div></div><p></p></div>

[英]why is this tetx not overflowing on the x axis even though I have a fixed width and the <p tag is set to display: block?

I need the text to overflow on the X axis just to reproduce some issue that I'm having on a bigger project.我需要文本在 X 轴上溢出只是为了重现我在更大项目中遇到的一些问题。 I leave a simple snippet, so you can tell me where I'm doing it wrong.我留下一个简单的片段,所以你可以告诉我我在哪里做错了。 Thanks!谢谢!

 .article { background-color: rgb(236, 161, 161); width: 20em; }.article p { display: block; }
 <article class="article"> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis deleniti iure quidem distinctio officia voluptates similique molestiae culpa? Perferendis, velit maiores nobis maxime aut facere eaque quis voluptas accusamus commodi.</p> </article>

If you want the p tag to overflow on the x-axis, you simply need to tell it not to wrap using the white-space property:如果您希望p标签在 x 轴上溢出,您只需要使用white-space属性告诉它不要换行:

p{ 
    white-space: nowrap;
}
暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使我将刻度间隔设置为每7天,为什么我的d3图表的x轴将每个月的第一天都作为刻度显示? - Why does my d3 chart's x-axis include the first of every month as a tick even though I set the tick interval to every 7 days? 加载页面时会出现一个文本框,即使我已将其“样式:显示”设置为无 - A text box appears when I load the page even though I have set its “style:display” to none 为什么即使我将create标志设置为true,getFile()也不创建任何文件? - Why isn't getFile() creating any files even though i have set the create flag on true? AngularJS:即使它们正确显示,为什么也要为此得到NaN? - AngularJS: Why am I getting NaN for this even though they display correctly? 即使我没有将任何字段设置为唯一,为什么 Mongo 会给我 E11000 错误? - Why is Mongo giving me the E11000 error even though I don't have any field set to unique? 为什么页面在 x 和 y 轴上都溢出并且也没有垂直居中? - Why the page is overflowing both in x and y axis and also not centering vertically? 为什么这个jQuery replace()在 - Why does this jQuery replace() not work in an <a tag, though I got it to work in a <p tag? 包含具有内嵌块显示的对象的div如何具有固定的高度和自动宽度? - How to have fixed height and auto width for a div containing objects with inline-block display? 当数据在X轴上时,如何在X轴上显示固定标签? - How can I display fixed labels on X-axis while having data on that axis? 即使需要设置webView contentEditable = true,如何阻止键盘出现? - How can I block the keyboard from appearing even though I need to set my webView contentEditable=true?
 
粤ICP备18138465号  © 2020-2023 STACKOOM.COM