@Fartown
2016-12-02T02:58:38.000000Z
字数 1714
阅读 509
a标签的使用
<a href="http://www.w3school.com.cn/" target="_blank">Visit W3School!</a>
首先,我们在 HTML 文档中对锚进行命名(创建一个书签):
<a name="tips">基本的注意事项 - 有用的提示</a>
然后,我们在同一个文档中创建指向该锚的链接:
<a href="#tips">有用的提示</a>
元素居中
多个块状元素解决方案:
垂直居中:
.item{
top: 50%;
margin-top: -50px;
position: absolute;
padding:0;
}
.item{
top: 50%;
position: absolute;
transform: translateY(-50%); /* 这里我们使用css3的transform来达到类似效果 */
}
.item{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.item{
background: #222;
color: #FFF;
width: 100px;
height: 100px;
}
.parent{
display: flex;
justify-content:center;
align-items: center;
background: #AAA;
height: 300px;
}
flex:
在flexbox纵向布局(即,flex-direction:column)中,如果我们需要控制子元素对齐的位置,可以使用如下两个 属性:align-items justify-content,align-items :控制纵向布局中子元素的左右对齐方式,justify-content :控制纵向布局中子元素的上下对齐方式