CSS:
.navbar a:link, a:visited {
background-color: goldenrod;
color: black;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family: Georgia, 'Times New Roman', Times, serif;
font-size: larger;
}
.navbar a:hover, a:active {
background-color: rgb(121, 130, 255);
}
HTML:
<div class="navbar">
<a href="html/home.html" target="_blank">Home</a>
<a href="html/about.html" target="_blank">About Us!</a>
<a href="html/properties.html" target="_blank">Property List</a>
<a href="html/terms.html" target="_blank">Terms & Conditions</a>
<a href="html/contact.html" target="_blank">Contact Us!</a>
</div>
我是 web 開發的初學者,嘗試只使用 CSS 和 HTML 制作網站,所以我陷入了這個問題,我似乎無法找到如何將所有這些按鈕放到適當的位置(標有紅色)在中心
我試著在谷歌上四處搜索,結果失敗了,嘗試了一些屬性,比如
align-items: center;
認為它會起作用但沒有。
請幫忙!謝謝你!
uj5u.com熱心網友回復:
假設目標是使按鈕居中(似乎找不到標有紅色的區域),您可以設定容器的樣式.navbar:
.navbar {
display: flex;
justify-content: center;
}
有關flex布局的更多資訊
希望這會有所幫助。
例子:
.navbar {
display: flex;
justify-content: center;
}
.navbar a:link, a:visited {
background-color: goldenrod;
color: black;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family: Georgia, 'Times New Roman', Times, serif;
font-size: larger;
}
.navbar a:hover, a:active {
background-color: rgb(121, 130, 255);
}
<div class="navbar">
<a href="html/home.html" target="_blank">Home</a>
<a href="html/about.html" target="_blank">About Us!</a>
<a href="html/properties.html" target="_blank">Property List</a>
<a href="html/terms.html" target="_blank">Terms & Conditions</a>
<a href="html/contact.html" target="_blank">Contact Us!</a>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/536699.html
上一篇:從'constchar*'賦值給'char'使指標成為整數而無需強制轉換
下一篇:從按鈕中反應數值的Suma
