我搜索了整個stackoverflow,所有答案都回傳了這個結果:

創建帖子和報告帖子曾經在同一行,并且作業正常,但是當我添加“后退”按鈕時,一切都在不同的行上。
這是我將按鈕居中的方式:

我用 DIV 標簽包裹了按鈕,并將 DIV 居中,使按鈕位于中心,但與創建帖子和報告帖子不在同一行。
我還在 DIV 上使用了一個 A 標記,因此它在單擊按鈕時重定向到主頁,效果很好。

關于如何將按鈕本身與創建帖子和報告帖子放在同一行,同時保持居中的任何想法?
順便說一下,這是之前和之后:
前:

后:

編輯:
正如 カメロン 在評論中指出的那樣,我忘了添加代碼片段,所以這里是:
導致問題的按鈕:
<a href="/">
<div style="display: flex; justify-content: center;">
<button style="color: black; font-weight: bold; box-shadow: 0px 0px 15px 0px #000000; border-radius: 7px; stroke-width: 0px; padding: 20px 50px; background-color: grey;">Back</button>
</div>
</a>
如果需要更多代碼,請在評論中告訴我 :)
編輯2:
下面是三個按鈕的代碼:
<a href="/post/create">
<button
style="color: black; font-weight: 1000; box-shadow: 0px 0px 15px 0px #ff0000; border-radius: 7px; stroke-width: 0px; padding: 20px 50px; background-color: rgb(0, 225, 255);">Create Post</button>
</a>
<a href="/">
<div style="display: flex; justify-content: center; ">
<button style="color: black; font-weight: bold; box-shadow: 0px 0px 15px 0px #000000; border-radius: 7px; stroke-width: 0px; padding: 20px 50px; background-color: grey;">Back</button>
</div>
</a>
<a href="/post/report">
<button
style="color: rgb(238, 255, 0); font-weight: 1000; box-shadow: 0px 0px 15px 0px #ff0000; box-shadow: 0px 0px 30px 0px #eeff00; border-radius: 7px; stroke-width: 0px; padding: 20px 50px; background-color: rgb(255, 0, 0); float: right;">Report post</button>
</a>
uj5u.com熱心網友回復:
如果添加,space-between您將解決錯誤
并將其寫入父級,其中所有元素1次
細節:
- 證明內容 MDN 檔案
- W3SCHOOL (playit) 之間的空格
<div class="container" style="display: flex; justify-content: space-between;">
<!-- left -->
<button>hello 1</button>
<!-- center -->
<button>hello 2</button>
<!-- right -->
<button>hello 3</button>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/405474.html
標籤:
上一篇:如何將元素的高度設定為HTML元素的實際所需高度,而不是CSS或JavaScript中的auto?
下一篇:如何使用按鈕重定向到另一個頁面?
