【发布时间】:2016-05-04 09:08:49
【问题描述】:
我的包装完全位于我的网站中心,但是当我将链接添加到其中的图标时,它们的位置发生了变化。我尝试再次将它们居中,但现在它似乎无法正常工作,因为当我更改缩放或调整页面大小时,它们不再位于中心。
HTML
<div class="wrappericons">
<a href="http://www.facebook.com"><div id="facebook"></div></a>
<a href="http://www.youtube.com"><div id="youtube"></div></a>
<a href="http://www.twitter.com"><div id="twitter"></div></a>
</div>
还有 CSS
.wrappericons {
margin: auto;
width: 15%;
background-color: none;
display: flex;
-webkit-display: flex;
-moz-display: flex;
align-items: center;
-webkit-align-items: center;
-moz-align-items: center;
padding-left: -20px;}
#facebook {
height: 60px;
width: 33,33%;
margin-left: 50%;
margin-right: 50%;
background-color: none;
background-image: url(icons/facebookgrey.svg);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
align-items: center;
-webkit-align-items: center;
-moz-align-items: center;
display: flex;
-webkit-display: flex;
-moz-display: flex;
min-width: 45px;
float: left;
position: relative;}
#facebook:hover {
background-image:url(icons/facebook.svg);}
#youtube {
height: 60px;
width: 33,33%;
margin-left: 75%;
background-color: none;
background-image: url(icons/youtubegrey.svg);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
align-items: center;
-webkit-align-items: center;
-moz-align-items: center;
display: flex;
-webkit-display: flex;
-moz-display: flex;
min-width: 45px;
float: left;
position: relative;}
#youtube:hover {
background-image:url(icons/youtube.svg);}
#twitter {
height: 60px;
width: 33,33%;
margin-left: 100%;
background-color: none;
background-image: url(icons/twittergrey.svg);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
align-items: center;
-webkit-align-items: center;
-moz-align-items: center;
display: flex;
-webkit-display: flex;
-moz-display: flex;
min-width: 45px;
float: left;
position: relative;}
#twitter:hover {
background-image:url(icons/twitter.svg);}
PS:我用 Chrome 看这段代码
【问题讨论】:
-
垂直居中、水平居中,还是两者兼而有之?
-
没有负填充之类的东西。