English 中文(简体)
重新调整窗口时限制居中 div 的横向水平范围
原标题:Limit horizontal range of centered div when resizing window

我有两个分母。 一个应该位于左窗口边框的5%, 另一个应该位于前面提到的分母的右侧, 与窗口宽度相对居中。 如果窗口太窄, 它不应该重叠第一个分母, 也不应该移动到下面 。

之后的事物应该位于前两个小分队的最高点以下。

我怎样才能做到这一点?

我最接近的是第一个 div 。 < a href="http://jsfiddle.net/7qVLm/" rel="no follow" >http://jsfiddle.net/7qVLm/

编辑:这里是我最满意的最后结果:http://jsfiddle.net/ATHpg/

感谢@Christopher Smithson和@gmebeh, 他们的回答帮助我找到解决办法。

最佳回答

来考虑一下你的解决方案

http://jsfiddle.net/f2Muj/5/

问题回答

以百分数为基础的 width s 您可以做到这一点 :

""http://jsfiddle.net/f2Muj/7," rel="no follow">jsFiddle

  • #d1 is 5% from the left, center-aligned content
  • #d2 is centered relative to the browser window, and will never overlap #d1
  • Both use fixed heights to accomodate fixed amounts of content

使用百分比来获取您想要的准确宽度 。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签