gpt4 book ai didi

html - Bootstrap,使用粘性页脚垂直和水平居中图像

转载 作者:太空宇宙 更新时间:2023-11-04 10:59:38 25 4
gpt4 key购买 nike

我在使用 Bootstrap 粘性页脚尝试将图像水平和垂直居中时遇到问题。它需要流畅、响应迅速,并且在台式机和移动设备上都能正常工作。如果窗口/屏幕尺寸太小(很明显),我不希望页脚覆盖图像。

任何帮助或见解将不胜感激!

这是我得到的..

404.php

<html lang="en">
<head>
<title>Error 404</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Error 404</title>

<!-- Bootstrap -->
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles -->
<link href="/assets/css/sticky-footer.css" rel="stylesheet">
<link href="/assets/css/custom.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>

<div class="container-fluid">
<div class="panel-default">
<div class="panel-body">
<div class="text-center top"><h2>Error 404</h2>
</div>

<div class="form-group text-center">
<h4>Nothing to see here, nothing to see</h4>
<img src="/assets/images/404.jpg" class="img-responsive center-block">
</div>

</div>
</div>
</div>

<footer class="footer">
<div class="container">
<p class="text-muted text-center">
<small>&copy; 2015</small>
</p>
</div>
</footer>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>

</body>
</html>

sticky-footer.css

/* Sticky footer styles */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 40px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 40px;
}

最佳答案

粘性底部页脚

Bootstrap 有一个导航栏,我发现它对页脚很有用。尝试使用 navbar navbar-default navbar-fixed-bottom 而不是您的自定义页脚类。

垂直居中

This question有很多关于垂直居中的重要信息。这是我使用的:

.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one :-) */

display: flex;
align-items: center;
}

水平居中

我发现最简单的水平居中解决方案就是使用 center-block。还没有让我失望。

关于html - Bootstrap,使用粘性页脚垂直和水平居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34438509/

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