gpt4 book ai didi

html - 为什么我的页脚中的链接包括右边距?

转载 作者:太空宇宙 更新时间:2023-11-04 03:04:05 26 4
gpt4 key购买 nike

我正在使用 Notepad++ 练习 HTML 和 CSS 技能,但在向页脚添加几个链接时遇到了问题。我遇到的问题是每个链接都包含 15px 的 margin-right 值(即可以单击每个链接之间的空白)。我希望能够只点击单词将我定向到该特定页面。

这是我的页脚 HTML 代码:

<body>
<div id="footer">
<div id="footerlinks">
<a href="index.html">
<span style="color: #FFFFCC">
<p class="footerlink">
HOME
</p>
</span>
</a>
<a href="about.html">
<p class="footerlink">
ABOUT
</p>
</a>
<a href="rooms.html">
<p class="footerlink">
ROOMS
</p>
</a>
<a href="divesite.html">
<p class="footerlink">
DIVE SITE
</p>
</a>
<a href="food.html">
<p class="footerlink">
FOOD
</p>
</a>
<a href="news.html">
<p class="footerlink">
NEWS
</p>
</a>
<a href="contact.html">
<p class="footerlink">
CONTACT
</p>
</a>
</div>
</div>
</body>

这是我的页脚 CSS:

#footer {
width: 100%;
height: 50px;
background-color: #999999;
border-bottom: 1px solid black;
padding-right: 20px;
padding-left: 20px;
clear: both;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

#footerlinks {
height: 100%;
line-height: 45px;
display: inline-block;
float: left;
}

#footerlinks a {
color: #333333;
}

#footerlinks a:link {
text-decoration: none;
}

#footerlinks a:hover {
color: #FFFFCC;
}

.footerlink {
font-size: 14px;
vertical-align: center;
margin-right: 15px;
display: inline;
}

这是我的 JSFiddle - https://jsfiddle.net/vu4qg17c/2/

我只在 JSFiddle 中包含了 HTML 和 CSS 代码的必要部分。先感谢您。

最佳答案

代替

<a href="about.html">
<p class="footerlink">
ABOUT
</p>
</a>

反转<a>的位置和 <p>

<p class="footerlink">
<a href="about.html">
ABOUT
</a>
</p>

对所有其他人做同样的事情。

写作 <a>之前 <p>使整个<p>作为链接。并且,作为 <p>有一些默认填充,没有文本的区域也可以点击。

关于html - 为什么我的页脚中的链接包括右边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30817635/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com