简体   繁体   English

如何使用媒体查询设置响应式页脚 | html - CSS

[英]How to set a responsive footer using media queries | html - CSS

I'm having a footer issue which must be responsive by using media queries.我有一个页脚问题,必须通过使用媒体查询来响应。

I would like to make it with a flex method but I can't find a way to get the requested result.我想用 flex 方法来实现它,但我找不到获得请求结果的方法。

Also, I think the organization of my html could be better.另外,我认为我的 html 的组织可能会更好。

If you guys could check this out if would appreciate it.如果你们可以检查一下,如果会很感激。 Thanks!谢谢!

Footer页脚

Responsive footer with 940px media query带有 940px 媒体查询的响应式页脚

 * { margin: 0; padding: 0; border: 0; box-sizing: border-box; list-style: none; text-decoration: none; } body { max-width: 1850px; font-family: "BenchNine", sans-serif; font-size: 1.5em; line-height: 1.5; }.flex { display: flex; } img { height: auto; width: 100%; vertical-align: top; } footer { padding: 1em; justify-content: space-around; background-color: #ededed; }.footer-link { color: #000; }.footer-link:hover { color: #999; } @media screen and (max-width: 940px) { }
 <footer class="flex"> <nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <picture> <img src="/img/logo.png" alt="logo"> </picture> </footer>

For example by using the percentage for the column width.例如,通过使用列宽的百分比。

footer {
  width: 100%;
  padding: 1em;
  /* justify-content: space-around; */
  background-color: #ededed;
}
footer nav, footer picture {
  display: block;
  width: 25%;
}
@media screen and (max-width: 940px) {
  footer nav, footer picture {
    width: 100%;
  }
}

Note that if you want more space for the picture, you can change the width of the columns, for example 3x nav 22%, and the picutre 34%请注意,如果您想要更多的图片空间,您可以更改列的宽度,例如 3x nav 22% 和 picutre 34%

 * { margin: 0; padding: 0; border: 0; box-sizing: border-box; list-style: none; text-decoration: none; } body { max-width: 1850px; font-family: "BenchNine", sans-serif; font-size: 1.5em; line-height: 1.5; }.flex { display: flex; flex-wrap: wrap; } img { height: auto; width: 100%; vertical-align: top; } footer { padding: 1em; background-color: #ededed; } footer > nav{flex-grow:1}.footer-link { color: #000; min-width: 190px; display: block; }.footer-link:hover { color: #999; } @media screen and (max-width: 940px) { }
 <footer class="flex"> <nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <ul class="footer-menu"> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> <li><a class="footer-link" href="#">Lorem</a></li> </ul> </nav> <picture> <img src="/img/logo.png" alt="logo"> </picture> </footer>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM