我想div用CSS垂直居中.我不想要表或JavaScript,只需要纯CSS.我找到了一些解决方案,但所有这些解决方案都缺少Internet Explorer 6支持.
<body>
<div>Div to be aligned vertically</div>
</body>
Run Code Online (Sandbox Code Playgroud)
如何div在所有主流浏览器(包括Internet Explorer 6)中垂直居中?
我正在尝试制作一个小的用户名和密码输入框.
我想问一下,你如何垂直对齐一个div?
我有的是:
<div id="Login" class="BlackStrip floatright">
<div id="Username" class="floatleft">Username<br>Password</div>
<div id="Form" class="floatleft">
<form action="" method="post">
<input type="text" border="0"><br>
<input type="password" border="0">
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如何使用id用户名和表单将div垂直对齐到中心?我试图把:
vertical-align: middle;
Run Code Online (Sandbox Code Playgroud)
在CSS中为id登录的div,但它似乎不起作用.任何帮助,将不胜感激.
我正在使用这个脚本水平和垂直居中我的div.
当页面加载时,div会垂直居中,而不是水平居中,直到我调整浏览器大小.
我究竟做错了什么?
$(document).ready(function (){
$(window).resize(function (){
$('.className').css({
position:'absolute',
left: ($(window).width() - $('.className').outerWidth())/2,
top: ($(window).height() - $('.className').outerHeight())/2
});
});
$(window).resize();
});
Run Code Online (Sandbox Code Playgroud) 我有三个不同的div标签(不在彼此内部)和代码,因此它有一个放置左,中或右的单词,但中心非常偏离中心.这是HTML代码:
.desc {
float: right;
color: skyblue;
}
.desc1 {
float: left;
color: skyblue;
}
.desc2 {
text-align: center;
color: skyblue;
}Run Code Online (Sandbox Code Playgroud)
<div class="desc1">
<h2>What we are here to do!</h2>
<p>Example</p>
</div>
<div class="desc2">
<h2>What we have completed</h2>
<p>Recent work (can include pictures)</p>
</div>
<div class="desc">
<h2>Company Description</h2>
<p>EXAMPLE!</p>
</div>Run Code Online (Sandbox Code Playgroud)