CSS Flexcontainer在Flex包装后不够高
该页脚具有flexcontainer(id =“ footerline”),其flex包装属性设置为包装。该容器包含两个Divs(类=“ FooterButton”)。当包装在小屏幕上发生时,第二个容器移至新线路,但是容器的高度没有调整,因此两条线重叠。我可以通过删除两个Divs中的按钮的填充来解决此问题,但这显然不是我想做的。
那么,我该怎么做才能确保Flexcontainer在包装后具有正确的高度(当然,在包装之前,但这不是问题)?将容器的高度设置为100px之类的东西是一个选择,因为我希望容器足够高以容纳内容,无论是否包装。
我研究了有关类似情况及其答案的许多其他问题,但是我从中产生的所有实验对我而言无济于事。
谢谢。
马尔特
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
#footerline {display:flex; justify-content: space-around; flex-wrap: wrap;
padding: 20px; width: 100%; background: #132a40}
.footerbutton a {color:whitesmoke; padding: 20px; margin-left:10px;
text-decoration: none; background-color: green}
</style>
</head>
<body>
<footer>
<div id="footerline">
<div class="footerbutton">
<a href="Imprint.html">Imprint -- Cookies -- Privacy</a>
</div>
<div>
<nav class="footerbutton">
<a href="english.html">English</a>
<a href="swedish.html">Swedish</a>
<a href="german.html">German</a>
</nav>
</div>
</div>
</footer>
</body>
</html>
This footer has a flexcontainer (id="footerline") whose flex-wrap property is set to wrap. The container contains two divs (class="footerbutton"). When wrapping takes place on small screens, the second container moves to a new line, but the container's height does not adjust, so the two lines overlap. I could fix this by removing the padding of the buttons in the two divs, but this is clearly not what I would like to do.
So what can I do to make sure the flexcontainer has just the right height after wrapping (and before wrapping, too, of course, but that is not the problem)? Setting the height of the container to something like 100px is not an option as I wish the container to be just high enough to contain the content, be it wrapped or not.
I have studied numerous other questions about similar situations and their answers, but all my experiments that resulted from this did not help in my case.
Thank you.
Malte
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
#footerline {display:flex; justify-content: space-around; flex-wrap: wrap;
padding: 20px; width: 100%; background: #132a40}
.footerbutton a {color:whitesmoke; padding: 20px; margin-left:10px;
text-decoration: none; background-color: green}
</style>
</head>
<body>
<footer>
<div id="footerline">
<div class="footerbutton">
<a href="Imprint.html">Imprint -- Cookies -- Privacy</a>
</div>
<div>
<nav class="footerbutton">
<a href="english.html">English</a>
<a href="swedish.html">Swedish</a>
<a href="german.html">German</a>
</nav>
</div>
</div>
</footer>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请在CSS中使用CSS中的页脚底部,
如果您在WebView中不需要,
只需在媒体查询中添加它即可。如果在WebView的位置不需要,则在媒体查询中的marginbottom
Please use footer bottom in css for Footerbutton
if you dont needed in Webview just add it in Media query.
if not needed in WebView place that Marginbottom in media query
检查有完整的代码
显示:flex
问题。如果您想在移动设备中的空间添加媒体查询
移动设备。Check there are full code
display: flex
issues here. if you want space in a mobile deviceadd media query
for mobile.我照顾你的代码。据我了解,您对Flex的方法无法正常工作。我建议在您的主要页脚线div中添加属性的最小值
min-height:200px
。此外,Flex仅包装页脚内部的两个div元素。您需要显示:flex
和flex-wrap:wrap
to foterline div中的两个div元素。尝试此解决方案,希望这会有所帮助。I looked after your code. From what I understood your approach to flex is not working right.I would suggest to add a property min-height say
min-height:200px
to your main footerline div. Also the flex is wrapping only the two div elements inside footer. You need to needdisplay:flex
andflex-wrap:wrap
to both the div elements inside your footerline div. Try this solution I hope this helps.尝试一下它为您工作
Try this it is working for you