javascript - 文本不会包裹在我的 flexbox 容器中

标签 javascript html css flexbox

我在尝试将文本放入我的 flexbox 容器时遇到问题,它只是溢出到右边的元素中,我怎样才能让两个文本都换行?

<div style="width:100%; height:auto; display:flex; outline:1px solid red;">
  <div style="width:30%; min-height:450px; outline:1px solid red; position:relative; display:flex;">
    <div style="width:100%; height:auto; display:flex; flex-direction:column; padding:25px;">
      <span style="font-size:20px; color:red; margin-bottom:20px; ">kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</span>
      <p style="font-size:15px; color:red; line-height:28px; margin-bottom:20px;">cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</p>
    </div>
  </div>
  <div style="width:70%; min-height:450px; outline:1px solid red; display:flex; flex-direction:column; padding:25px; ">
    <table class="section_menu_pala_item_table" data-menu="entrantes" style="width:100%; border:none;">
      <tr class="section_menu_pala_item_row" style="margin-bottom:4px;">
        <th class="section_menu_pala_item_header" style="border:none; text-align:left;" width="15%">Plato</th>
        <th class="section_menu_pala_item_header" style="border:none;" width="1%">1/2</th>
        <th class="section_menu_pala_item_header" style="border:none;" width="1%">1</th>
      </tr>
      <!--append rows here-->
    </table>
  </div>
</div>

最佳答案

我推荐使用word-wrap: break-word。与 word-break 相比,它只会在整个单词不能放在自己的行上而不会溢出时创建一个中断。

作为旁注,我强烈建议开始使用外部 CSS 样式表和类,因为使用内联您将无法重用样式等,并且在与所有样式混合时更容易出错且更难维护标记。

堆栈片段

<div style="width:100%; height:auto; display:flex; outline:1px solid red;">
    <div style="width:30%; min-height:450px; outline:1px solid red; position:relative; display:flex;">
	    <div style="width:100%; height:auto; display:flex; flex-direction:column; padding:25px;">
		    <span style="word-wrap: break-word;font-size:20px; color:red; margin-bottom:20px; ">kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</span>
			<p style="word-wrap: break-word;font-size:15px; color:red; line-height:28px; margin-bottom:20px;">cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</p>
		
		</div>
	
	</div>
	<div style="width:70%; min-height:450px; outline:1px solid red; display:flex; flex-direction:column; padding:25px; ">
	    <table class="section_menu_pala_item_table" data-menu="entrantes" style="width:100%; border:none;">
            <tr class="section_menu_pala_item_row" style="margin-bottom:4px;">
		        <th class="section_menu_pala_item_header" style="border:none; text-align:left;" width="15%">Plato</th> 
                <th class="section_menu_pala_item_header" style="border:none;" width="1%">1/2</th>
                <th class="section_menu_pala_item_header" style="border:none;" width="1%">1</th> 
            </tr>
            <!--append rows here-->
        </table>
	
	
	</div>







</div>

关于javascript - 文本不会包裹在我的 flexbox 容器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51179335/

相关文章:

javascript - 单击输入类型=搜索时重置按钮有任何事件吗?

JavaScript 图表库 - Google Analytics 风格

javascript - addEventListener 适用于 code pen 但不适用于 visual studio code

javascript - 尽管横幅的大小是固定的,但 Adsense 仍显示空白广告

php - 我如何使用 cookie 来存储购物车内容?

javascript - 按类型单击 Selenium 中的元素

css - 网站的教程模式荧光笔

javascript - 用 d3 将测地线钳制到最小/最大纬度

javascript - 在 Json 中填充子对象

css - 自动居中并保持 Div 中图像的纵横比