0

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>
4
  • 1
    Can you make a js fiddle for your code? Commented May 13, 2014 at 9:34
  • a Jsfiddle would be helpful Commented May 13, 2014 at 9:38
  • Indeed a Jsfiddle would be very helpfull.. ` Commented May 13, 2014 at 9:39
  • yes here it is : jsfiddle.net/78akK/1 Commented May 13, 2014 at 9:40

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes I could probably do that with JavaScript and mainly even make it working with tablet and smartphone. But i'm asking that because it's an exercise I create myself to improve my CSS and when I was looking after tutorial I found that done on Zen CSS Garden... I have the css but it's a little to complicated for a beginner in css as me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.