Css 图像水平滚动页面,无边框/填充,垂直居中!可能的
我看过很多水平滚动和垂直居中内容的例子,但没有一个是组合的——这似乎创造了一个真正的挑战!还有头疼 这里是我的位置-页面滚动良好,但内容没有垂直居中,图像周围有空格:nowrapCss 图像水平滚动页面,无边框/填充,垂直居中!可能的,css,Css,我看过很多水平滚动和垂直居中内容的例子,但没有一个是组合的——这似乎创造了一个真正的挑战!还有头疼 这里是我的位置-页面滚动良好,但内容没有垂直居中,图像周围有空格:nowrap <style type="text/css"> body{ background:#272727; } .wrapper { display: table; table-layout: fixed; width: 10
<style type="text/css">
body{
background:#272727;
}
.wrapper {
display: table;
table-layout: fixed;
width: 100%;
height: 100%;
overflow: auto;
}
.container {
display: table-cell;
vertical-align: middle;
}
.content {
float:left;
white-space: nowrap;
padding:0;
margin:0;
}
img {
display:inline;
border:none;
padding:0;
margin:0;
}
</style>
你能添加你的HTML+并演示一下你目前所拥有的吗?我还将有一些JSFIDDLE,试试jquery怎么样?只需将我编辑过的答案粘贴到你的页面上,就在结束标记之前。并删除您在应用程序上的内联样式
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script>
$(document).ready(function(){
var screenHeight = $(document).height();
var contentHeight = 733;
var difference = (screenHeight - contentHeight)/2;
alert(difference);
$('.content').css({'margin-top': difference});
});
</script>