0

The problem is I have 2 divs side by side. On the right div I have a really long content. I have given a right-border to the left div so that it acts as a separator. But the border doesnt extend to end of the contents on the right div.

Here a sample on JSfiddle http://jsfiddle.net/zQw44/

This is my html

    <!DOCTYPE html>
<html>

    <head>
        <link rel="stylesheet" type="text/css" href="site.css">
    </head>

    <body>
        <header >
            <div style="background-color:silver">
            this is header
            </div>
        </header>
        <div class="main-wrap">
            <div id="center" >
                <div id="left" class="clearfix"> left </div>
                <div id="right" class="clearfix"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).


Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.

There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. 
                 </div>
            </div>
        </div>
        <div class="footer">Footer</div>
    </body> 
</html> 

and this my css

html, body {
    height: 100%;
}

body
{
    margin: 0;
    padding:0;
}

.main-wrap {
    position: absolute;
    /*top: 50px;
    bottom: 50px;*/
    width: 100%;
    height:100%;
} 

#center
{
    width:960px;
    margin:0 auto;
    text-align:left;
    height:100%;

    /*overflow: auto;*/
} 

#left
{
   float:left;
   width:200px;
   height:100%;
   border-right:1px solid black;
   padding-top:10px;
}

#right
{
    width:760px;
    margin-left:220px;
    padding-top:10px;
    height:100%;
    position:absolute;
}

.footer {
    height: 50px;
    width: 100%;
    background-color: lightblue;
    position: fixed;
    bottom: 0;
}


.clearfix:before,
        .clearfix:after {
          content: ".";
          display: block;
          height: 0;
          overflow: hidden;
        }

        .clearfix:after {
            clear: both;
        }

        .clearfix {
            zoom: 1; /* IE < 8 */
        }
user1131926
  • 1,311
  • 2
  • 18
  • 32

5 Answers5

1

The reason the border is not extending to the bottom of the right content is because the height is considerably smaller. I would suggest putting a border-left on the right side like below and also change height: 100%; to height: auto;

#left
{
   float:left;
   width:200px;
   height:100%;   
   padding-top:10px;
}

#right
{
    width:760px;
    margin-left:220px;
    padding-top:10px;
    height:auto;
    border-left:1px solid black;
    position:absolute;
}

You will need to put padding on the right section so that the border does not touch the text.

J Prakash
  • 1,323
  • 8
  • 13
Jay
  • 772
  • 1
  • 6
  • 17
  • I think this is the simplest solution. The questioner could also look here for a more involved answer on giving floated divs equal height: http://stackoverflow.com/questions/1122381/how-to-force-child-div-to-100-of-parents-div-without-specifying-parents-heigh – John_C Jul 21 '14 at 11:13
  • Instead of changing border right to left , why don't you try overflow property? – Gibbs Jul 21 '14 at 11:14
  • I didn't use the overflow property because then it only scrolls on the right content rather than the page. I do not believe that is the best way of doing this. – Jay Jul 21 '14 at 11:17
  • @jay Pls mention my name at comments. I agree with you. But whats the problem with overflow? Isn't designed for this purposes na? – Gibbs Jul 21 '14 at 11:21
  • @Jay My friend your solution is not working please put your fiddle. – J Prakash Jul 21 '14 at 11:21
  • Your name is too long for me to be bothered typing sorry!...well of course thats it purpose for the desired effect of it. I dont think in this case thats the desired effect. – Jay Jul 21 '14 at 11:22
  • Thanks for the help guys. I removed the position:absolute though on the right. It works without it as well. – user1131926 Jul 21 '14 at 11:46
  • Yes it will do :) i figured you had took the code out of its context and therefore i thought it may be needed. – Jay Jul 21 '14 at 11:55
0

Demo

Reason: Parent content' height is 100% . Your right content data is greater than it's height. You din't specify overflow property. So it takes extra height. But left content's height is less than 100%. So Right margin of left is upto 100%.

Solution:

#right
{
 width:760px;
 margin-left:220px;
 padding-top:10px;
 height:100%;
 position:absolute;
 overflow: scroll;
}
Gibbs
  • 21,904
  • 13
  • 74
  • 138
0

Try the following CSS

Demo

#right
{
    width:760px;
    margin-left:200px;
    padding-left: 20px;
    padding-top:10px;
    height:auto;
    position:absolute;
    border-left: 1px solid black;
}
amol
  • 1,535
  • 9
  • 10
0

Because it's smaller than right. Just add overflow: auto on right.

html, body {
height: 100%;
}

body
{
    margin: 0;
    padding:0;
}

.main-wrap {
    position: absolute;
    /*top: 50px;
    bottom: 50px;*/
    width: 100%;
    height:100%;
} 

#center
{
    width:960px;
    margin:0 auto;
    text-align:left;
    height:100%;

    /*overflow: auto;*/
} 

#left
{
   float:left;
   width:200px;
   height:100%;
   border-right:1px solid black;
   padding-top:10px;
}

#right
{
    width:760px;
    margin-left:220px;
    padding-top:10px;
    height:100%;
    position:absolute;
    border-right: 1px solid black;
    overflow: auto;
}

.footer {
    height: 50px;
    width: 100%;
    background-color: lightblue;
    position: fixed;
    bottom: 0;
}


.clearfix:before,
        .clearfix:after {
          content: ".";
          display: block;
          height: 0;
          overflow: hidden;
        }

        .clearfix:after {
            clear: both;
        }

        .clearfix {
            zoom: 1; /* IE < 8 */
        }
St3f4NS
  • 21
  • 2
0

try this code DEMO

#right {
    border-left: 1px solid black;
    margin-left: 220px;
    padding-left: 10px;
    padding-top: 10px;
    position: absolute;
    width: 760px;
   /* height:100%;*/
}
Alex Wilson
  • 2,421
  • 11
  • 13