Mathese F
Mathese F

Reputation: 559

CSS div overflow hidden and Float

I'm trying something very simple :

Creating a body with a text on the left and taking all the available space for an amount of px from a max to a min and it could float. On the right on that div I want to add a new div that will contain a menu at the end.

I took a look on this forum and tried multiple things but I cannot achieve what I want.

I want my #rightcolumn on the right when it's possible and when it's not, it should just be hidden.

I successfully found everything I want but never at same time.

I worked with related position, with inline instead of float and without float it's not on the same line.

Here is my actual code :

    <!DOCTYPE html>
<html>
<head>
<style>
html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed,
    figure, figcaption, footer, header, hgroup,
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    }
    /* HTML5 display-role reset for older browsers */
    article, aside, details, figcaption, figure,
    footer, header, hgroup, menu, nav, section {
    display: block;
    }
    body {
    line-height: 1;
    }
    ol, ul {
    list-style: none;
    }
    blockquote, q {
    quotes: none;
    }
    blockquote:before, blockquote:after,
    q:before, q:after {
    content: '';
    content: none;
    }
    table {
    border-collapse: collapse;
    border-spacing: 0;
    }



img 
{
float:bottom;

border:1px dotted black;
margin:0px 0px 15px 20px;
}
p {
    padding: 10px;
}

#rightcolumn{
    margin-left: -150px;
    width: 150px;
    height: 100px;
/*  float:left;*/
    background: #CC33FF;
float:left;
overflow:hidden;
    }

#wrapper {
    width: 100%;
    min-width: 1000px;
    max-width: 1000px;
    margin: 0 auto;
white-space:nowrap;

}


#contentliquid {
    float: left;
    width: 100%;
    min-width: 1000px;
float:left;
}

#content {

    background: #FFFFFF;
    margin-left: 0px;
    min-width: 1000px;
float:left;
}

</style>
</head>

<body>
<div id="wrapper">

    <div id="contentliquid">
        <div id="content">
            Test coucou
            </div>
    </div>

<div id="rightcolumn">
            <p>This is right</p>
        </div>

</div>
</body>

</html>

Upvotes: 0

Views: 139

Answers (1)

user3631948
user3631948

Reputation: 85

If I understand your question correct. I would say it would be easy using JavaScript

$(document).ready(function(){ var length_of_content = $('#content').width();

if((length_of_content+$('#rightcolumn').width()) >= 500) {
    $('#rightcolumn').css('display', 'none');
}

});

Just check the lenngth of the current content and add your width of the menue you wanna display, if the width is >= 500 or whatever your maxsize of the container should be, then simply hide the menue wiht #rightmenue otherwise show it.

Upvotes: 1

Related Questions