English 中文(简体)
无论页数大小,如何将两个要素放在彼此旁边
原标题:how to position two elements next to each other regardless of page size
  • 时间:2012-04-11 12:02:04
  •  标签:
  • css
  • position

我试图在我的网页上做一个讲解语的风格。 想法是,在我的旁边厅,如果我点击一个环节,就会把旁遮挡在左边,暴露这一联系会到哪里。 为了做到这一点,我会同时制造两条旁障,即明显的旁边bar和下一个旁边bar,隐藏在另一个因素后面。

旁边关的一个例子见。 http://jsfiddle.net/gpcC6/7/

The problem I m having, is when the window is resized, the second sidebar goes under the first. I want to to stay to the right, even if it means that it goes off the side of the screen. Is this possible? Thanks

最佳回答

在有<代码>white-space: nowrap的集装箱内规定副管,并使之成为<代码>的显示:有线24,而不是按您的指示浮动。


注:white-space: nowrap in some browsers will interpret thespace between two divs in the RUS as an actualspace

<div>
</div><!-- SPAAAAAACE -->
<div>
</div>

取消这种间隔,你需要将这些间隔放在同一线上。

<div>
</div><div>
</div>

或者,你可以向母体添加一个<代码>font:0;,在这种情况下,该集装箱也将消除间隔,但必须明确确定在你之前所有元素的体积,否则,所有儿童元素的体积也将达到0;]

, 问题


Sample | Code

CSS

div{
    font-size: 16px;
}

#topbar {
    height: 40px;
    background-color: blue;
}

.wrapper{
    white-space: nowrap;
    font-size: 0;
}

.sidebar {
    width: 200px;
    display: inline-block;  
    white-space: normal;
}

.title {
    height:30px;
    background-color: red;
}

.main {
    height: auto;
    overflow: scroll;
}

传真

<div id="topbar">
    hello
</div>
<div class= wrapper >
    <div class="sidebar">
        <div class="title">
            title
        </div>
        <div class="main">
            blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
        </div>

    </div>
    <div class="sidebar">
        <div class="title">
            title
        </div>
        <div class="main">
            blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
        </div>      
    </div>
</div>
问题回答

围绕你的酒吧进行包装,给它固定的 w或min。 然后,你只能看看一下,你的旁边关在相互毗邻的这个包装箱里。 即便窗户较小,而且你能够横向发展,这些保障也相互保持。





相关问题
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....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

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 ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签