我正在努力改进我的投资组合网站(www.kikidesign.net),目前正在处理页脚。我试图使其响应,其中链接(带有图标)将能够保持不变,但将重新安排以响应浏览器窗口。例如,对于桌面版,它将在一行中,但对于平板电脑版,它将是两行,每行有两个链接,而对于移动版,它就像一个列表。但是,我无法将图标和文字保存在一个地方。当我移动浏览器窗口时,图标会不断弹出。我该怎么做才能解决它?
HTML
<div id="footercontent">
<ul class="ca-menu">
<li class="about2">
<a href="<?php echo get_option('home'); ?>/about" >
<span class="aboutimg"></span>About Me
</a>
</li>
<li class="contact2">
<a href="<?php echo get_option('home'); ?>/contact" >
<span class="contactimg"></span>Contact
</a>
</li>
<li class="download">
<a href="kikidesignResume.pdf">
<span class="downloadimg"></span>Resume
</a>
</li>
<li class="facebook">
<a href="https://www.facebook.com/kikidesignnet" >
<span class="facebookimg"></span>Facebook
</a>
</li>
</ul>
</div>
CSS
#footercontent {
position: relative;
padding-top: 15px;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
min-height: 100px;
}
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
width: 23%;
height: 100%;
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
#footercontent .ca-menu li a {
text-decoration: none;
text-align: left;
font-family: 'PrintClearlyRegular';
font-weight: normal;
font-style: normal;
font-size: 1.75em;
}
#footercontent .ca-menu li a:hover {
text-decoration: underline;
text-decoration-color: white;
-moz-text-decoration-color: white;
-webkit-text-decoration-color: white;
-o-text-decoration-color: white;
-ms-text-decoration-color: white;
}
.ca-menu li:hover .aboutimg, .ca-menu li:hover .contactimg, .ca-menu li:hover .downloadimg, .ca-menu li:hover .facebookimg {
color: #ffffff;
/**font-size: 30px;**/
opacity: 1;
}
.aboutimg {
display: inline-block;
width: 50px;
height: 60px;
text-align: center;
background: url(images/girlIcon2.png) no-repeat 0 0;
opacity: 0.3;
vertical-align: middle;
margin-top: -10px;
margin-right: 10px;
}
.ca-menu .about2 a {
color: #f9a145;
border: none;
text-decoration: none;
}
#contactimg {
padding: 15px 0 12px 0;
}
.contactimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/contact.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .contact2 a {
color: #4595d1;
border: none;
text-decoration: none;
padding: 20px;
}
.downloadimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/download.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .download a {
color: #f7e400;
border: none;
text-decoration: none;
padding: 20px;
}
.facebookimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/facebook.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .facebook a {
color: #B0B0B0;
border: none;
text-decoration: none;
padding: 20px;
}
答案 0 :(得分:0)
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
我已对这两部分进行了修改。
对于移动设备:
@media (max-width: 480px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 100%;
}
}
您也可以为其他尺码做同样的事情:
@media (min-width: 480px) and (max-width: 720px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 40%;
}
}
<强> DEMO 强>