簡體   English   中英

Flexbox 和絕對定位在 Chrome 和 Safari 中不起作用

[英]Flexbox and absolute positioning not working in Chrome and Safari

我有一個具有以下樣式的按鈕類:

 .button { align-items: center; background-color: #fff; border: 2px solid; border-color: #f48120; color: #f48120; cursor: pointer; display: inline-flex; font-size: 20px; font-weight: bold; justify-content: center; margin-bottom: 5px; padding: 3px 10px; position: relative; text-transform: lowercase; } .button::after { background-color: #fff; bottom: -4px; content: '\\f111'; display: flex; font-family: 'FontAwesome'; font-size: 5px; justify-content: center; position: absolute; width: 25%; }
 <button class="button">Enviar</button>

如果我取消選中然后再次檢查檢查器中的“位置:絕對”屬性,則圓圈會在中心對齊。 這是一個 Blink/Webkit 錯誤嗎?

絕對元素不會被父元素定位。 只需將其放置在左側並將其轉換為居中即可。

只是一個旁注,沒有必要使用display: flex; 在絕對元素上。

 .button { align-items: center; background-color: deeppink; border: 2px solid; border-color: aqua; cursor: pointer; display: inline-flex; font-size: 20px; font-weight: bold; justify-content: center; margin-bottom: 5px; padding: 3px 10px; position: relative; text-transform: lowercase; } .button:after { content: ''; background-color: deepskyblue; bottom: -4px; font-size: 5px; position: absolute; width: 25%; height: 10px; left: 50%; transform: translateX(-50%); }
 <button type="button" class="button">Submit</button>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM