这个问题已经困扰我一段时间了,我还没有确定一个解决方案,并尝试了几种方法。我正在尽可能地保持我的标记语义。我已经搜索过类似的问题,但我在将问题抽象到足以找到适用的解决方案时遇到了困难。
我觉得关于我的快速介绍是为了解释我的设计方法。首先,我不是一个设计师。我没有接受过正式的培训,但我找到了一份程序员的工作。我从11岁(1997)就开始涉足web工作,并在高中(2000-2004)深受Web标准运动的影响。直到几个月前,他们还没有考虑过网络工作。我工作的公司已经付钱给一个设计师,让他在photoshop中开发一个设计,然后又要付钱给另一个人来做CSS的工作。这让我困惑不已,我决定站出来试一试,到目前为止一切都很好。
然而,我让一个烦人的问题溜走了。我们有一个搜索表单,已被设计为一个3列的框。由于我的工作性质,我不得不对这个盒子进行一些抽象。框在webkit中呈现正确,但在firefox,opera,特别是IE (未图示)中,中心列将不会保持正确位置。在这些浏览器的老版本中看起来更糟。这可能是检验一个实际例子的好时机:http://jsfiddle.net/KdFT7/

我应该简要解释一下其中的一些标记。当一个人点击'add X‘按钮时,将出现一个模式窗口,其中包含选择X个项目的选项,这将被附加到带有类XChoice的div中,而所选的总数将被附加到带有下面的XSelected类的段落()中。理想情况下,框从小开始并随着项目的增加而增长是很好的,但这给我带来了如何更新AddY的中心列和框的问题。总的来说,我对设计不满意,但我的工作是编写代码,而不是批评它。
我需要一双全新的眼睛。我如何标记这一点,并应用正确的样式,允许3列在大多数浏览器中齐平。我很理解这一点,但我非常感谢大家对这个问题的任何尝试。标记可以更改,css可以重新装备,但不幸的是,设计需要保持一致。
HTML
<div class="rightCol">
<div class="addX">
<h2><span class="tiny">Add</span>X</h2>
<span class="ui-corner-tl ui-widget-header ui-widget-borderfix"></span>
<div class="innerContent ui-padding-med ui-widget-content">
<form>
<input type="radio" id="radio-0" name="radio" checked="checked" /><label for="radio-0" class="ui-spacer-med">And</label>
<input type="radio" id="radio-1" name="radio" /><label for="radio-1" class="ui-spacer-med">Or</label><br />
</form>
<p class="descrip ui-spacer-med"> Click the button to lookup and select X for your search </p>
<div class="XChoice"></div>
<p class="xSelected"></p>
<!-- brings up modal form -->
<a href="addX.htm" class="addXButton">Add X</a> </div>
<span class="ui-corner-bl ui-widget-header ui-widget-borderfix"></span>
</div>
<div class="centerCol">
<span class="ui-widget-header ui-widget-borderfix"></span>
<form class="clause ui-widget-content ui-padding-med">
<input type="radio" id="radio-2" name="radio" checked="checked" /><label for="radio-2">And</label><br />
<input type="radio" id="radio-3" name="radio" /><label for="radio-3">Or</label><br />
<input type="radio" id="radio-4" name="radio" /><label for="radio-4">Not</label><br />
</form>
<span class="ui-widget-header ui-widget-borderfix"></span>
</div>
<div class="addY">
<h2><span class="tiny">Add</span>Y</h2>
<span class="ui-corner-tr ui-widget-header ui-widget-borderfix"></span>
<div class="innerContent ui-padding-med ui-widget-content">
<form>
<input type="radio" id="radio-5" name="radio" checked="checked" /><label for="radio-5" class="ui-spacer-med">And</label>
<input type="radio" id="radio-6" name="radio" /><label for="radio-6" class="ui-spacer-med">Or</label><br />
<input type="input" value="Enter Y(s)" /><br />
</form>
<a href="#" id="example">example</a>
<ol>
<li> We should find an example to put here?</li>
<li> Examples? </li>
<li> Yes, perhaps 3 solid examples </li>
</ol>
</div>
<span class="ui-corner-br ui-widget-header ui-widget-borderfix"></span>
</div>
<div class="addSubGroup ui-corner-all ui-widget-content">
<a class="rg ui-icon ui-icon-circle-minus" title="Remove Sub Group">Remove Sub Group</a> <a class="ag ui-icon ui-icon-circle-plus" title="Add Sub Group">Add Sub Group</a>
</div>
<span class="sub-clause">
<form class="ui-corner-all ui-widget-content">
<input type="radio" id="radio-7" name="radio" checked="checked" class="ui-spacer-med" /><label for="radio-7">And</label>
<input type="radio" id="radio-8" name="radio" class="ui-spacer-med" /><label for="radio-8">Or</label>
<input type="radio" id="radio-9" name="radio" class="ui-spacer-med" /><label for="radio-9">Not</label>
</form>
</span>
</div>CSS
* { margin: 0; padding: 0; zoom: 0; }
body, html {font: .9em/1.1em HelveticaNeue, Helvetica, Arial, sans-serif;}
.addY,
.addX{ float: left; max-width: 370px; min-width: 218px; width: 43%; }
.addSubGroup { float: left; margin: -1em 0 0 80%; padding: .25em .5em; width: 2.5em; }
.ag,
.rg { float: left;}
.centerCol { float: left; margin-top: 3.05em; max-width: 66px; min-width: 46px; }
.clause { border-left: 1px solid #fff; border-right: 1px solid #fff; height: 210px; margin: 0 auto; }
#example { margin-left: 1em; }
#example+ol { display: none; line-height: 1.5em; margin-left: 2.5em; }
.rightCol { float: right; height: 350px; margin: -1em 1% 2%; width: 73%; }
.sub-clause { display: none; float: left; margin: 2% 0 1% 5%; text-align: center; width: 80%; }
.ui-widget-borderfix { display: inherit; height: 1.25em; }
h2 { color: #222; font: 2.2em/1em Georgia, serif; }
.rightCol h2 { margin: .5em 0 -.25em .45em; }
.innerContent { height: 210px; }
.ui-widget-content { background: #eee; color: #000000; }
.ui-widget { font-family: Arial,sans-serif; font-size: .8em; }
.ui-padding-med { padding: .5em; }
.tiny { font-size: .65em }同样,在这里可以找到一个活的例子:http://jsfiddle.net/KdFT7/
PS。
另外,这个问题与我问过的另一个问题有关,但没有得到可靠的答案:Clone and update attributes
发布于 2011-06-06 05:59:41
我只在Chrome,火狐和IE8上测试过,但它似乎有帮助..
总结:我通过绝对定位h2从流中移除了它们,然后移除了它们引起的高度差异。为此,请执行以下操作:
创建addX, addY {position: relative;},以便定位的h2与它们保持相对
在addX、addY和centerCol中添加相等的上边距(足以将标题放入其中),所有需要的内容都会被清除
添加position: absolute的h2,并删除所有的页边距和填充,然后给他们一个负的顶值弹出到你的盒子的顶部。
副作用:.ui-widget-content还需要添加position: relative;,以便在定位的addX和addY div上恢复
Working Example
https://stackoverflow.com/questions/6244790
复制相似问题