指向其他网页的链接指向同一网页

  • 本文关键字:网页 其他 链接 html css
  • 更新时间 :
  • 英文 :


我得到了两个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,链接正常工作

使用h1h2上的left:0pxright: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>

最新更新