gpt4 book ai didi

html - 在 Microsoft Edge 中使用内联 block 显示问题

转载 作者:行者123 更新时间:2023-11-28 03:12:06 26 4
gpt4 key购买 nike

这是问题所在:我试图通过使用 display: inline-block 将两个“p”元素对齐在同一行来创建一个页面,“p”中的内联 block 和最后一个带有 float: right 的子元素。该代码在 Chrome 中运行良好,但当我在 Edge 中尝试时,我注意到一个小问题:页脚没有按应有的方式位于页面底部,而是创建了一个至少 1px 的空白区域。

Google Chrome 中的页面 View :/image/qfCkl.png

Microsoft Edge 中的页面 View :/image/bFHz1.png

但是如果我将正文的背景颜色更改为与页脚相同,则边距“消失”。

问题是我不想更改主体的颜色,也不想使用 position: absolute 来放下页脚,因为我试图以这种方式修复它并且它有效但我不想使用该属性。不知道是不是Edge显示的问题,还是代码错了大家可以告诉我。这是代码:

<html>
<body>
<div class="wrapper">
<div class="content">
<!-- content of the page -->
</div>
</div>

<footer>
<div class="copyright">
<p>Footer text</p>
<p>More Footer text</p>
</div>
</footer>
</body>
</html>

这是 CSS:

* {
box-sizing: border-box;
margin: 0px;
padding: 0px;
}

body {
font-family: Sans-Serif;
}

.wrapper, footer {
width: 100%;
}

.content {
margin: 0 auto;
height: 1000px;
width: 90%;
}

footer {
background-color: #333;
}

.copyright {
padding: 20px;
}

.copyright p {
color: #fff;
display: inline-block;
padding: 0px 20px;
}

.copyright p:last-child {
float: right;
}

最佳答案

* {
box-sizing: border-box;
margin: 0px;
padding: 0px;
}

body {
font-family: Sans-Serif;
}

.wrapper, footer {
width: 100%;
}

.content {
margin: 0 auto;
height: 1000px;
width: 90%;
}

footer {
background-color: #333;
}

.copyright {
padding: 20px;
}

.copyright p {
color: #fff;
display: inline-block;
vertical-align: middle;
padding: 0px 20px;
}

.copyright p:last-child {
float: right;
}
        <div class="wrapper">
<div class="content">
<!-- content of the page -->
</div>
</div>

<footer>
<div class="copyright">
<p>Footer text</p>
<p>More Footer text</p>
</div>
</footer>

请添加vertical-align: middle;.copyright p

关于html - 在 Microsoft Edge 中使用内联 block 显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45657135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com