Jquery ui 如何将文本和文本框一个接一个对齐。帮助我,而且我必须在页面的中间位置对齐,而不是在顶部中心 是否有人知道如何在页面中间对齐一个div,而不是在顶部中心。它必须有白色背景。请在这方面帮助我。帮助我实现这一目标,而不是
我的部门是Jquery ui 如何将文本和文本框一个接一个对齐。帮助我,而且我必须在页面的中间位置对齐,而不是在顶部中心 是否有人知道如何在页面中间对齐一个div,而不是在顶部中心。它必须有白色背景。请在这方面帮助我。帮助我实现这一目标,而不是,jquery-ui,jquery,jquery-mobile,Jquery Ui,Jquery,Jquery Mobile,我的部门是 <div data-role="fieldcontain" > 用户名: <div id="b" style="display: inline-block"> <label for="password"><font size="1" color="black">Password : </font></label> <input type="password" name="password" id="pwd
<div data-role="fieldcontain" >
用户名:
<div id="b" style="display: inline-block">
<label for="password"><font size="1" color="black">Password : </font></label>
<input type="password" name="password" id="pwd" data-mini="true" value="" style="width: 45%;float: right"/></div>
嗯,不确定这是否正是您要查找的内容,但假设页面中没有其他内容,您可以通过这种方式在页面中居中放置元素
<div id='b'>
some element
</div>
<style>
#b{
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
margin: auto;
width: 100px;
height: 10px;
}
</style>
假设您的divclass是一个位于中间的div
.YourDivClass
{
position: fixed;
left: 50%;
top: 50%;
background-color: white;
z-index: 100;
height: 400px;
margin-top: -200px;
width: 600px;
margin-left: -300px;
}
由于jQuery Mobile独特的功能,纯CSS无法用于完美的内容中心化 下面是一个专门为jQM创建的工作示例:
通常水平居中只能通过css实现,但由于新的jQM 1.3更改,甚至必须通过javascript进行计算 那么数据角色是页面中唯一的元素吗?如果有些人想知道他在说什么。
$(document).on('pageshow', '#index', function(){
$("div[data-role='fieldcontain']").css('margin-top',getRealContentHeight()/2 - $('#b').height()/2);
$('#b').css('margin-left',$("div[data-role='content']").outerWidth()/2 - $('#b').width()/2);
});
function getRealContentHeight() {
var header = $("div[data-role='header']:visible");
var footer = $("div[data-role='footer']:visible");
var content = $("div[data-role='content']:visible:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
content_height -= (content.outerHeight() - content.height());
}
return content_height;
}