第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

在flexbox中使div填充剩余*水平*空間

在flexbox中使div填充剩余*水平*空間

瀟湘沐 2019-07-30 16:47:20
在flexbox中使div填充剩余*水平*空間我在flexbox中有兩個div并排。右手應該總是相同的寬度,我希望左手一個只抓住剩余的空間。但除非我專門設定寬度,否則不會。所以目前,它設置為96%,看起來沒問題,直到你真的擠壓屏幕 - 然后右手div有點缺乏它所需的空間。我想我可以保留它,但它感覺不對 - 就像必須有一種說法:合適的人總是一樣的; 你在左邊 - 你得到了剩下的一切.ar-course-nav {   cursor: pointer;   padding: 8px 12px 8px 12px;   border-radius: 8px;}.ar-course-nav:hover {   background-color: rgba(0, 0, 0, 0.1);}<br/><br/><div class="ar-course-nav" style="display:flex; justify-content:space-between;">   <div style="width:96%;">     <div style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">       <strong title="Course Name Which is Really Quite Long And Does Go On a Bit But Then When You Think it's Stopped it Keeps on Going for even longer!">                 Course Name Which is Really Quite Long And Does Go On a Bit But Then When You Think it's Stopped it Keeps on Going for even longer!            </strong>     </div>     <div style="width:100%; display:flex; justify-content:space-between;">       <div style="color:#555555; margin-right:8px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" title="A really really really really really really really really really really really long department name">         A really really really really really really really really really really really long department name      </div>       <div style="color:#555555; text-align:right; white-space:nowrap;">         Created: 21 September 2016      </div>     </div>   </div>   <div style="margin-left:8px;">     <strong>&gt;</strong>   </div></div>
查看完整描述

2 回答

?
HUH函數(shù)

TA貢獻1836條經驗 獲得超4個贊

使用該flex-grow屬性可使Flex項目占用主軸上的可用空間。

此屬性將盡可能擴展項目,將長度調整為動態(tài)環(huán)境,例如屏幕重新調整大小或添加/刪除其他項目。

一個常見的例子是flex-grow: 1或使用速記屬性flex: 1

因此,不要width: 96%使用你的div,而是使用flex: 1。


你寫了:

所以目前,它設置為96%,看起來沒問題,直到你真的擠壓屏幕 - 然后右手div有點缺乏它所需的空間。

壓縮固定寬度div與另一個flex屬性有關: flex-shrink

默認情況下,將flex項設置為flex-shrink: 1允許它們縮小以防止容器溢出。

要禁用此功能,請使用flex-shrink: 0。

有關詳細信息,請參閱答案中flex-shrink因子部分:


了解有關沿主軸的柔性對齊的更多信息:

在此處了解有關沿交叉軸的柔性對齊的更多信息:


查看完整回答
反對 回復 2019-07-30
?
繁星coding

TA貢獻1797條經驗 獲得超4個贊

基本上我試圖讓我的代碼在'行'上有一個中間部分來自動調整兩邊的內容(在我的例子中,是一個虛線分隔符)。就像@Michael_B建議的那樣,關鍵是display:flex在行容器上使用,并至少確保行上的中間容器的flex-grow值至少為1(如果外部容器沒有flex-grow應用任何屬性)。

這是我試圖做的圖片以及我如何解決它的示例代碼。

編輯:虛線底部邊框可能看起來很奇怪,具體取決于瀏覽器的顯示方式。我個人建議使用黑色圓圈SVG作為重復的背景圖像,尺寸合適并定位在中間容器的底部。當我有時間時,會添加這個替代解決方案。

.row {
  background: lightgray;
  height: 30px;
  width: 100%;
  display: flex;
  align-items:flex-end;
  margin-top:5px;}.left {
  background:lightblue;}.separator{
  flex-grow:1;
  border-bottom:dotted 2px black;}.right {
  background:coral;}
<div class="row">
  <div class="left">Left</div>
  <div class="separator"></div>
  <div class="right">Right With Text</div></div><div class="row">
  <div class="left">Left With More Text</div>
  <div class="separator"></div>
  <div class="right">Right</div></div><div class="row">
  <div class="left">Left With Text</div>
  <div class="separator"></div>
  <div class="right">Right With More Text</div></div>


查看完整回答
反對 回復 2019-07-30
  • 2 回答
  • 0 關注
  • 1964 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

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

公眾號

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