html - 运行 localhost 时 Href 不工作

标签 html css

所以我正在使用 html、php 所有有趣的东西设计一个网站,并且我正在尝试制作 facebook、twitter、youtube 和 instagram 将打开新标签页的链接并带你到网站。但目前 URL 转到 localhost/horizo​​nphotography/www.facebook.com 而不是打开新选项卡然后转到 www.facebook.com

这是我的 HTML

<div class="social">      
    <a href="www.facebook.com" target="_blank">
    <img border="0" alt="Facebook" src="img/facebook.png" width="50" height="50">
    </a>

    <a href="www.twitter.com" target="_blank">
    <img border="0" alt="twitter" src="img/twitter.png" width="50" height="50">
    </a>

    <a href="www.youtube.com" target="_blank">
    <img border="0" alt="youtube" src="img/youtube.png" width="50" height="50">
    </a>

    <a href="www.instagram.com" target="_blank">
    <img border="0" alt="instagram" src="img/instagram.png" width="50" height="50">
    </a>
</div> 

和我的 css 'if' 需要。

.social {
    position: fixed;
    bottom: 0;
    right: 7%;
    width: 300px;
}

提前致谢!

最佳答案

尝试使用像 http://// 这样的协议(protocol)来连接这样的外部链接:

<a href="http://www.facebook.com" target="_blank">
<img border="0" alt="Facebook" src="img/facebook.png" width="50" height="50">
</a>

在 SO 上看到这个很好的答案:https://stackoverflow.com/a/8951636/6028607

关于html - 运行 localhost 时 Href 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36674458/

相关文章:

javascript - 当使用 jQuery 切换隐藏 div 时,使用 jquery 添加/更改 CSS

javascript - React/Babel 如何在单选按钮中添加逻辑?

css - HTML 没有正确链接到 CSS

javascript - JQuery 切换数字和字符输入

jquery - 滚动/跟随侧边栏帮助

css - 堆叠 Canvas 移除默认透明度 HTML

html - 设置表格单元格内容的最大高度

html - 在容器中生成图像中的 css3 动画

PHP MySqli 多查询 & while 在一页中 - 有助于简化代码

javascript - 从 jquery 对象获取 HTML 元素的类型