我有一个页脚,可以随时响应,直到在移动设备上查看为止。在移动设备上观看时,页脚在容器/ div后面被向上推,同时页脚下方还留有一小块空白。
我尝试使用各种页脚,div,容器等。我目前正在使用flex,并且页脚在台式机/平板电脑上可以正常工作。想知道我是否需要针对移动设备的媒体查询。
.footer {
display: flex;
justify-content: center;
height: 300px;
width: 100%;
background-color: orange;
margin-top: 300px;
}
<div class="footer">
<p>
testing to see if can move to bottom
</p>
</div>
只是希望在社交媒体图标上有一个漂亮的页脚,它始终位于底部并在移动设备上响应。
答案 0 :(得分:0)
如果您将主体页边距重置为0px,则可能会有所帮助。例如,在Chrome浏览器中,body标签默认具有8px的边距。
在实现自己的样式之前,请尝试实现标准的重置CSS,以防止浏览器默认设置更改布局并更统一地呈现元素。
body {
background-color: black;
padding:0px;
margin: 0px;
}
.footer {
display: flex;
justify-content: center;
height: 300px;
width: 100%;
background-color: orange;
margin-top: 300px;
}
<div class="footer">
<p>
testing to see if can move to bottom
</p>
</div>
重置CSS的示例
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}