在网页设计中,a标签是我们常用的标签之一,它可以用来定义页面中的链接。如果我们需要在点击a标签时打开一个新的窗口,该怎么做呢? 其实很简单,只需要在a标签中添加一个target属性,取值为"...
在网页设计中,a标签是我们常用的标签之一,它可以用来定义页面中的链接。如果我们需要在点击a标签时打开一个新的窗口,该怎么做呢?
其实很简单,只需要在a标签中添加一个target属性,取值为"_blank"即可。具体代码如下所示:
<a href="http://www.example.com" target="_blank">这是一个链接</a>
<a href="http://www.example.com" class="pop-up">点击打开小窗口</a>
.pop-up {
display: inline-block;
padding: 10px;
border: 1px solid #ccc;
}
<br>
.pop-up:hover {
cursor: pointer;
}
<br>
.pop-up:active {
position: fixed;
top: 50%;
left: 50%;
width: 300px;
height: 200px;
margin-top: -100px;
margin-left: -150px;
background-color: #fff;
box-shadow: 0 0 10px #ccc;
z-index: 999;
}