如何优化网站Footer布局:实现Kategoriler与Referanslar并排显示
核心修改点
- 调整列布局逻辑,确保全尺寸屏幕下两区域稳定并排
- 缩减Footer内边距、行高与元素间距,解决尺寸过大问题
- 修复响应式断点错误,优化小屏幕显示效果
修改后的完整代码
CSS部分
.site-footer { background-color: rgb(226, 109, 128); /* 缩减上下内边距,压缩Footer整体高度 */ padding: 25px 0 15px; font-size: 15px; line-height: 20px; /* 缩小行高,让内容更紧凑 */ color: #ffffff; } .site-footer hr { border-top-color: rgb(255, 255, 255); opacity: 0.5; /* 缩减分割线上下间距 */ margin: 15px 0; } .site-footer h6 { color: rgb(0, 0, 0); font-size: 16px; text-transform: uppercase; margin-top: 0; /* 移除顶部空白 */ margin-bottom: 10px; /* 调整与列表的间距 */ letter-spacing: 2px; } .site-footer a { color: #ffffff; } .site-footer a:hover { color: #eeafdd; text-decoration: none; } .footer-links { padding-left: 0; list-style: none; margin: 0; /* 移除默认margin,减少空白 */ } .footer-links li { display: block; margin-bottom: 6px; /* 缩小列表项间距 */ } .footer-links a { color: #ffffff; } .footer-links a:active, .footer-links a:focus, .footer-links a:hover { color: #000000; text-decoration: none; } .footer-links.inline li { display: inline-block; } .site-footer .social-icons { text-align: right; } .site-footer .social-icons a { width: 40px; /* 缩小社交图标尺寸 */ height: 40px; line-height: 40px; margin-left: 6px; margin-right: 0; border-radius: 100%; background-color: #33353d; } .copyright-text { margin: 0; padding: 5px; font-size: 14px; /* 缩小版权文字尺寸 */ } @media (max-width:991px) { .site-footer [class^=col-] { margin-bottom: 15px; /* 缩减列底部间距 */ } } @media (max-width:767px) { .site-footer { padding-bottom: 0; } .site-footer .copyright-text, .site-footer .social-icons { text-align: center; } /* 小屏幕下用flex强制两列并排 */ .footer-row { display: flex; flex-wrap: wrap; } .footer-row .col-xs-6 { flex: 0 0 50%; max-width: 50%; } } .social-icons { padding-left: 0; margin-bottom: 0; list-style: none; } .social-icons li { display: inline-block; margin-bottom: 4px; } .social-icons li.title { margin-right: 15px; text-transform: uppercase; color: #96a2b2; font-weight: 700; font-size: 13px; } .social-icons a { background-color: #eceeef; color: #818a91; font-size: 16px; display: inline-block; line-height: 44px; width: 44px; height: 44px; text-align: center; margin-right: 8px; border-radius: 100%; transition: all .2s linear; } .social-icons a:active, .social-icons a:focus, .social-icons a:hover { color: #fff; background-color: #060708; } .social-icons.size-sm a { line-height: 34px; height: 34px; width: 34px; font-size: 14px; } .social-icons a.facebook:hover { background-color: #ff0606; } .social-icons a.twitter:hover { background-color: #00aced; } .social-icons a.linkedin:hover { background-color: #0f86fd; } .social-icons a.dribbble:hover { background-color: #e86969; } /* 修复原代码中错误的响应式断点 */ @media (max-width:767px) { .social-icons li.title { display: block; margin-right: 0; font-weight: 600; } }
HTML部分
<footer class="site-footer"> <div class="container"> <!-- 添加footer-row类,用于小屏幕flex布局控制 --> <div class="row footer-row"> <div class="col-xs-6 col-md-3"> <h6>Kategoriler</h6> <ul class="footer-links"> <li><a href="index.html">Anasayfa</a></li> <li><a href="hakkımda.html">Hakkımda</a></li> <li><a href="projelerim.html">Projelerim</a></li> <li><a href="fotogaleri.html">Fotogaleri</a></li> <li><a href="iletisim.html">İletişim</a></li> </ul> </div> <div class="col-xs-6 col-md-3"> <h6>Referans Linkleri</h6> <ul class="footer-links"> <li><a href="https://www.adu.edu.tr/" target="_blank"> Adnan Menderes Üniversitesi</a></li> <li><a href="https://hakanguleryuz.com.tr/" target="_blank">Hakan Güleryüz</a></li> <li><a href="elcinerbil.com.tr" target="_blank">Elçin Erbil</a></li> <li><a href="https://afranurkalafat.com.tr/" target="_blank">Afra Nur Kalafat</a></li> <li><a href="https://eylulidilozeren.com/" target="_blank">Eylül İdil Özeren</a></li> <li><a href="http://busramelekuzdu.com.tr/" target="_blank">Büşra Melek Uzdu</a></li> <li><a href="https://realbusenurcetin.tech/sitemap.xml" target="_blank">Sitemap</a></li> </ul> </div> </div> <hr> </div> <div class="container"> <div class="row"> <div class="col-md-8 col-sm-6 col-xs-12"> <p class="copyright-text">Copyright © 2022 All Rights Reserved by <a href="#">Buse Nur Çetin</a>. </p> </div> <div class="col-md-4 col-sm-6 col-xs-12"> <ul class="social-icons"> <li><a class="Github" href="https://github.com/busenurcetin" target="_blank"><i class="fab fa-github"></i></a></li> <li><a class="twitter" href="https://twitter.com/busenurcetin16" target="_blank"><i class="fab fa-twitter"></i></a></li> <li><a class="dribbble" href="https://realbusenurcetin.tech/" target="_blank"><i class="fab fa-safari"></i></a></li> <li><a class="linkedin" href="https://www.linkedin.com/in/busenur-%C3%A7etin-349b05253/" target="_blank"><i class="fab fa-linkedin"></i></a></li> </ul> </div> </div> </div> </footer>
修改说明
并排显示保障:
- 原HTML中
col-md-3已确保中等及以上屏幕两列并排;新增footer-row类配合flex布局,强制小屏幕下两列保持50%宽度并排 - 修复原CSS中错误的响应式断点
max-width:7px为max-width:767px
- 原HTML中
尺寸精简优化:
- 缩减Footer上下内边距,压缩整体高度
- 缩小行高、列表项间距与分割线间距,减少无效空白
- 缩小社交图标与版权文字尺寸,让底部区域更紧凑
内容的提问来源于stack exchange,提问作者Buse Nur
相关产品推荐
相关产品推荐

