我得到了两个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,链接正常工作
使用h1
和h2
上的left:0px
和right:0px
,可以从左向右扩展标头,一个覆盖另一个。
在其中一个上仅设置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>