亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Flex容器中的文本不會在IE11中包裝

Flex容器中的文本不會在IE11中包裝

繁星點點滴滴 2019-06-29 10:17:12
Flex容器中的文本不會在IE11中包裝考慮以下片段:.parent {  display: flex;  flex-direction: column;  width: 400px;  border: 1px solid red;  align-items: center;}.child {  border: 1px solid blue;}<div class="parent">  <div class="child">    Lorem Ipsum is simply dummy text of the printing and typesetting industry  </div>  <div class="child">    Lorem Ipsum is simply dummy text of the printing and typesetting industry  </div></div>有已知的解決辦法嗎?
查看完整描述

3 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

將此添加到代碼中:

.child { width: 100%; }

我們知道,塊級子應該占據父級的全部寬度。

Chrome明白這一點。

無論出于什么原因,IE11都想要一個明確的請求。

使用flex-basis: 100%flex: 1也很管用。

.parent {
  display: flex;
  flex-direction: column;
  width: 400px;
  border: 1px solid red;
  align-items: center;}.child {
  border: 1px solid blue;
  width: calc(100% - 2px);       /* NEW; used calc to adjust for parent borders */}
<div class="parent">
  <div class="child">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry  </div>
  <div class="child">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry  </div></div>

注意:有時需要對HTML結構的各個級別進行排序,以確定哪個容器獲得width: 100%不在IE中工作的CSS包裝文本


查看完整回答
反對 回復 2019-06-29
?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

我也有同樣的問題,重點是元素沒有調整其寬度以適應容器。

而不是使用width:100%保持一致(不要混合浮動模型和FLEX模型)并通過添加以下內容來使用FLEX:

.child { align-self: stretch; }

或:

.parent { align-items: stretch; }

這對我有用。


查看完整回答
反對 回復 2019-06-29
?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

泰勒在這里的一個注釋中,建議使用

max-width: 100%;

孩子可能會工作(為我工作)。使用align-self: stretch只有當你不使用align-items: center(我做到了)。width: 100%只有當你沒有多個孩子在你的柔印盒,你想要并排顯示。


查看完整回答
反對 回復 2019-06-29
  • 3 回答
  • 0 關注
  • 651 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號