English 中文(简体)
液态布局中水平对齐 divs 的横向对齐 divs - 一个背景延伸到另一个背景
原标题:Horizontally aligned divs in liquid layout - background of one extends behind other
  • 时间:2012-05-22 11:28:37
  •  标签:
  • html
  • css

我有一个液态布局。 我需要 2 divs 水平相邻, 并使用全部可用的宽度 。 第二 div 必须是其内容的宽度, 因此第一 div 将会占用其余的空间 。

Here is my attempt: http://jsfiddle.net/jamesbrighton/N2prR/2/

除了# 按钮后面有其它背景外, 它的工作方式是 。 Im my actual site # other 右侧也有背景图像设置。 这意味着我需要背景颜色和图像, 才能扩展至 # 按钮, 而不是范围以外 。

问题回答

两者中的第1项均应浮动。 (如果没有,则存在于不同的“层次”和重叠中)

至于自动宽度问题, 我不认为您可以用 html 轻易做到。 在我的经验中, 它总是比较适合使用 设置的宽度/ 高度与 divs 一起工作 。

如果您想要的话, 您可以使用 2 td 表格( 一个设定为100%宽度, 另一个设定宽度 - 例如 200px)

祝你好运

<style>
#other {
    background-color: blue;
width: 40%;
}
#button {
   background-color: gold;
   float: right;
   border-radius: 10px;
   width: 60%; 
}
.clear{
   clear: both;
}

<div id="parent"> 
 <div id="button">
    Submit Submit Submit Submit Submit Submit Submit Submit Submit Submit
 </div> 
 <div id="other"> 
   Some other content
 </div>
<div class="clear"></div>
</div> 

您必须给第 1 & lt; div> 以百分比固定一些 。 第二段的文字会自动折叠 。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签