Html 我如何制作包装纸<;部门>;垂直居中且反应灵敏? < P> >我希望我的包装卷滚动部分中的图像浮动在屏幕的中间(宽),如果屏幕变大,放大/缩小。目前它位于页眉下方,但远高于页脚。如何使其垂直居中
CSS: HTML:Html 我如何制作包装纸<;部门>;垂直居中且反应灵敏? < P> >我希望我的包装卷滚动部分中的图像浮动在屏幕的中间(宽),如果屏幕变大,放大/缩小。目前它位于页眉下方,但远高于页脚。如何使其垂直居中,html,css,Html,Css,CSS: HTML: <!-- section that contains all pics --> <section id="wrapper"> <article class="post"> <p><img src="img/scroll/001_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnon
<!-- section that contains all pics -->
<section id="wrapper">
<article class="post">
<p><img src="img/scroll/001_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/002_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/003_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/004_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/005_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
</section>
<!-- close section -->
提前谢谢各位 如果您想使用CSS表,我建议:
.post {
display: table;
}
.post p {
display: table-cell;
vertical-align: middle;
height: inherit; /* may not be needed */
}
display:table{-cell}
属性在较新的浏览器中得到了很好的支持,因此这应该可以做到这一点。一些解决方案想到了如何垂直居中div
#wrapper {
float:left; /**REMOVE THIS**/
margin:110px 0 0 0; /** REMOVE THIS **/
padding:0 0 0 250px; /** REMOVE THIS **/
width: 100%; /** ADD THIS **/
height: 100% /** ADD THIS **/
background:#fff;
position:relative; /** REMOVE THIS **/
z-index:2; /** REMOVE THIS **/
border-bottom:solid 20px #fff; /** REMOVE THIS **/
}
HTML
在此线程上找到可能的解决方案,但没有选择答案可能重复
#wrapper {
float:left; /**REMOVE THIS**/
margin:110px 0 0 0; /** REMOVE THIS **/
padding:0 0 0 250px; /** REMOVE THIS **/
width: 100%; /** ADD THIS **/
height: 100% /** ADD THIS **/
background:#fff;
position:relative; /** REMOVE THIS **/
z-index:2; /** REMOVE THIS **/
border-bottom:solid 20px #fff; /** REMOVE THIS **/
}
#wrapper {
width: 100%;
height: 100%;
min-height: 100%;
background:#fff;
position: absolute;
}
.post {
padding:0 5px 0 0;
background:#fff;
height:100%;
}
#wrapper img {
color:#fff;
width:auto;
}
#content {
position: relative;
width: 60%;
height: 60%;
top: 50%;
left: 50%;
}
<section id="wrapper">
<div id="content"> <!-- ADD THIS This will be used to position vertically-->
<article class="post">
<p><img src="img/scroll/001_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/002_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/003_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/004_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>
<article class="post">
<p><img src="img/scroll/005_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>