Jump to content

absolute causes text wrap?


ifubad

Recommended Posts

Here's a test page http://ifubad.awardspace.com/absolute.html

 

There's a floated list within div.b (black), that DIV's position is set to absolute, the text automatically wraps according to the width of div.a (red), unless a large enough width was specified for div.b. But if DIV b position was set to relative instead, then it it will not wrap.

 

How come absolute forces the container to fit within a positioned parent container, unless a width is specified, while relative does not?

 

I tried using white-space:nowrap, doesn't work. Is there a way to force it not to wrap, if I cannot use a specified width?

 

    div.a {

        width: 100px;

        border: 1px solid red;

        position: relative;

    }

 

    div.b {

        border: 1px solid;

        position: absolute;

        left: 50px;

    }

 

    ul {

        list-style: none;

        padding: 0;

        margin: 0;

    }

 

    li {

        float: left;

    }

    </style>

<body>

    <div class="a">

 

        <div class="b">

            <ul>

                <li>Link 1</li>

                <li>Link 2</li>

            </ul>

        </div>

 

    </div>

</body>

</html>

Link to comment
Share on other sites

Trying to use a background image or using an <img> tag and setting opacity, and placing it behind a floated <ul> menu that's been centered to page using position relative.

 

So far, the only way that I can think of, is to put the img container below the ul container, setting the ul container DIVs, some to relative and absolute, the relative container will collapse to allow the img tag to move up and behind the ul menu.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.