我有兩個 HTML 標題,一個在右上角,一個在左上角。出于某種原因,h1:s 鏈接合并到 h2:s 鏈接,我不知道為什么。
我的 CSS:
h1{
font-size: 35px;
color: black;
position: fixed;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
text-align: left;
}
h2{
font-size: 35px;
color: black;
position: fixed;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
text-align: right;
}
我的 HTML:
<a href="projects.html"><h1>my work</h1></a>
<a href="projects2.html"><h2>other work</h2></a>
當我洗掉位置時:固定;從CSS,鏈接正常作業
uj5u.com熱心網友回復:
使用left:0pxandright:0px在兩者上h1,h2您將標題從左到右延伸,一個覆寫另一個。
只設定left一個,只right設定另一個。
h1{
left: 0;
font-size: 35px;
color: black;
position: fixed;
margin-left: auto;
margin-right: auto;
text-align: left;
background-color:green;
}
h2{
right: 0;
font-size: 35px;
color: black;
position: fixed;
margin-left: auto;
margin-right: auto;
text-align: right;
background-color:red;
}
<a href="projects.html"><h1>my work</h1></a>
<a href="projects2.html"><h2>other work</h2></a>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/442464.html
上一篇:省略拋出的非void函式模板的return陳述句是否有效
下一篇:Boostrap5水平居中導航欄
