css - 无法将文本框与外部 div 对齐

标签 css dojo

演示:http://jsfiddle.net/57M68/ .我已经尝试了很多东西,比如 float 、边距、填充,但我无法让文本框在黑条的中心垂直对齐。请帮忙。代码:

html:

<body class="claro" data-maq-flow-layout="true" data-maq-comptype="desktop" data-maq-ws="collapse" style="margin-top:0" data-maq-appstates="{}" id="myapp">
 <div id="top_bar">
 <div style="width: 900px; height:50px; margin-left: auto; margin-right: auto;">
<a href="/" class="logo logo_a">
 <div class="logo">

 </div>
</a>
<div style="display:inline-block"> <input type="text" ></input></div>
</div>

</div>
 <div id="top_bar_divider"></div>
 <div data-dojo-type="dijit.layout.BorderContainer" persist="false" gutters="true" style="min-width: 1em; min-height: 1px; z-index: 0; width: 600px; height: 687px; margin-left: auto; margin-right: auto;" design="headline">
   <div data-dojo-type="dijit.layout.ContentPane" extractContent="false" preventCache="false" preload="false" refreshOnShow="false" region="center" splitter="false" maxSize="Infinity">
  </div>
 </div>
</body>

js:

require([
  "dijit/dijit",
  "dojo/parser",
  "maqetta/space",
  "maqetta/AppStates",
  "dijit/layout/BorderContainer",
  "dijit/layout/ContentPane",
  "dijit/form/TextBox"
]);

CSS:

html,body {
    height: 100%;
    width: 100%;
}

 .logo_a{
background:url("icon1.png");
}
.logo{
width:60px;
height:50px;
display:inline-block;
}
.logo_a:active{
background-position:0 1px;
}

#top_bar{
    padding:0px; 
    background: -webkit-linear-gradient(#464646, #121212);
    background: -moz-linear-gradient(#464646, #121212);
    background: -ms-linear-gradient(#464646, #121212);
    background: -o-linear-gradient(#464646, #121212);
    background: linear-gradient(#464646, #121212);
    color: #ccc;
    text-shadow:none;
    height:50px;
    width:100%;
}
#top_bar_divider{
background-color:#1ba0e1;
height:4px;
width:100%;
}

最佳答案

你只需要添加 vertical-align: middle 到你的输入 div 和 .logo_a:

.logo_a {
    background:url("icon1.png");
    vertical-align: middle;
}

http://jsfiddle.net/57M68/1/

关于css - 无法将文本框与外部 div 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15603811/

相关文章:

css - IE 中的链接有奇怪的行为

当内容在小屏幕上换行时,CSS 展开 div

javascript - 使用 javascript onmousemove 更改动画 css 属性?

jquery - Kendo UI kendoTreeList ExportToExcel : "Uncaught ReferenceError: count is not defined", 与聚合列

javascript - Dojo promise 一切——但这需要等待所有 promise 的返回

html - 将图像悬停添加到链接

html - 从 SVG 链接到外部样式表时为 "Security restrictions"(作为图像嵌入时)

javascript - jquery 的 .data() 方法的 Dojo 等价物

javascript - Dgrid 格式化程序根据另一列中的值创建列

Dojo 1.7.2 无法使用本地文件