Why is the inner div trying to clear other divs? - html

*NEW UPDATED JSFiddle http://jsfiddle.net/qKP2v/8/*
I have a very simple layout of two sidebars floated left and right respectively. In the middle is a #maincontent div that has a #content div within it. The reason for this is so that the main content on the page can stretch to fill the size of the browser resolution.
The problem I have is when I want to insert divs (#rectanglebox1, #rectanglebox2, #rectanglebox3) that clears left and right floats within my #content div. But the #rectanglebox divs are trying to clear the sidebars which doesn't make any sense to me. The #rectanglebox divs are within the #content area which has no float applied to it. So why is the #rectanglebox div being pushed below the sidebars?
Here is my HTML:
<div id="wrapper">
<div id="maincontent">
<div id="aside-left">
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>
<div id="aside-right">
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>
<div id="content">
<div id="ataglance">
<div id="rectanglebox1"><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p></div>
<div id="rectanglebox2"><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p></div>
<div id="rectanglebox3"><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p></div>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
And here is my CSS:
#wrapper {
width:100%;
margin: 0 auto;
background-color: #FFF;
min-height:200px;
border: 1px solid #F0F;
}
#aside-left {
height: 400px; /* guess */
float:left;
width:100px;
top: 0;
left: 0;
border: 1px solid #9C0;
}
#maincontent {
border: 1px solid #9C0;
width:100%;
}
#maincontent #content{
margin:0 130px;
border: 1px solid red;
}
#aside-right {
height: 400px; /* guess */
float:right;
width:100px;
top: 0;
right: 0;
text-align: right;
border: 1px solid #9C0;
}
#ataglance {
border: 2px solid black;
}
#rectanglebox1 {
float:left;
margin-top:5px;
border: 1px solid orange;
width:200px;
}
#rectanglebox2 {
float:left;
margin-top:5px;
border: 1px solid orange;
width:250px;
}
#rectanglebox3 {
float:left;
margin-top:5px;
border: 1px solid orange;
width:300px;
}

try this code it's working for me !
<div id="wrapper">
<div id="maincontent">
<div id="aside-left">
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>
<div id="aside-right">
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>
<div id="content">
<div id="rectanglebox"><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur</p></div>
<div style="clear:both;"></div>
</div>
<!-- <div style="clear:both;"></div> no need for this -->
</div>
</div>
and modify your css :
#rectanglebox {
margin-top:30px;
border: 1px solid orange;
float:left;
}

Related

3 Divs - Sticky Header, Sticky Footer, Dynamic Content Area, All Centered Vertically, Content Centered Horizontally

Using HTML and CSS, I'm attempting to achieve a seemingly simply layout with three components : a stickied header, a stickied footer, and a middle area that is 100% of whatever space is left in the browser window. I'd also like my entire site to be centered horizontally.
I've searched for and applied various answers from this forum, but nothing seems to work once I start to apply new characteristics to the page.
I'd like to also absolute center what will be a horizontal table in the above-mentioned content area, as well as position elements in the header and footer -- But I can't seem to get the basics down. What am I doing wrong?
#site {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
}
#header {
width: 1024px;
height: 120px;
display: table-cell;
vertical-align: middle;
background-color: aqua;
}
#content {
width: 1024px;
height: 100%;
vertical-align: middle;
background-color: red;
}
#footer {
width: 1024px;
height: 120px;
display: table-cell;
vertical-align: middle;
background-color: aqua;
}
.logo {
display: inline-block;
vertical-align: middle;
}
.item {
display: table-cell;
}
.copy {
font-size: 12pt;
font-family: Arial;
display: inline-block;
vertical-align: middle;
}
.l1nk {
display: inline-block;
vertical-align: middle;
}
.l2nk {
display: inline-block;
vertical-align: middle;
}
<div id="site">
<div id="header">
<img class="logo" src="Images/logo.png" alt="logo" height="60" width="195" />
</div>
<div id="content">
<img class="item" src="Images/item.png" alt="logo" height="150" width="150" />
</div>
<div id="footer">
<div class="copy">xoxo &copy xoxo </div>
<div class="l1nk">
<img src="Images/insta100.png" alt="instagram" height="25" width="25" />
</div>
<div class="l2nk">
<img src="Images/twttr100.png" alt="twitter" height="25" width="25" />
</div>
</div>
I'm new to this forum, and a novice programmer, so I'll roll with the punches. But I'd like a stronger foundation so that I can move forward with my code. Thanks so much
Personal I would use flexbox to accomplish this but an easy way to do it as well with out having to learn flexbox looks a little something like this
https://jsfiddle.net/kriscoulson/2fqu03b2/
this one has content in the content block
https://jsfiddle.net/kriscoulson/2fqu03b2/1/
HTML
html, body {
height: 100%;
padding: 0;
margin: 0;
}
.container {
width: 1024px;
height: 100%;
position: relative;
}
.header {
background-color: cyan;
height: 120px;
}
.content {
background-color: red;
height: calc(100% - 240px);
overflow: auto;
}
.footer {
width: 100%;
height: 120px;
background-color: cyan;
position: absolute;
bottom: 0;
}
<div class="container">
<div class="header"> header </div>
<div class="content"> content </div>
<div class="footer"> footer </div>
</div>
You can use the calc function in css to help determine the height since you know that the header is 120px and the footer is 120px we know that is 240px total that the content will not take up.
// EDIT
This is with the use of flexbox if you are trying to learn flexbox to do it
https://jsfiddle.net/kriscoulson/2fqu03b2/2/
html, body {
height: 100%;
padding: 0;
margin: 0;
}
.container {
width: 1024px;
height: 100%;
display: flex;
flex-direction: column;
}
.header {
background-color: cyan;
height: 120px;
}
.content {
background-color: red;
overflow: auto;
flex: 1;
}
.footer {
width: 100%;
height: 120px;
background-color: cyan;
justify-content: flex-end;
}
<div class="container">
<div class="header"> header </div>
<div class="content"> <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus fugit atque magni quis at, voluptate consectetur voluptates laboriosam distinctio beatae quos sunt architecto? Quis nihil optio incidunt a, ad iure!</div>
<div>Obcaecati expedita maiores ab. Tempora alias culpa, error quasi, quia delectus. Ratione, sapiente, at repellendus aspernatur debitis nesciunt eum fuga quibusdam in, suscipit omnis minima vero error perspiciatis, eaque corrupti?</div>
<div>Ullam praesentium doloremque inventore! Similique dolor delectus, consequatur at doloremque quibusdam sed ullam officiis molestias dignissimos doloribus in obcaecati explicabo ipsum ducimus et error, atque. Itaque consequatur perspiciatis dignissimos eligendi!</div>
<div>Maxime natus asperiores autem nobis in dicta necessitatibus consequuntur et expedita architecto molestias veniam, voluptate adipisci corporis qui sed modi sunt saepe sapiente vel voluptatem placeat facere nihil repudiandae. Cumque?</div>
<div>Rerum quod asperiores reprehenderit itaque sunt repellat natus nostrum, modi exercitationem impedit odit adipisci voluptates, facilis eligendi eum ex accusamus tenetur omnis fugiat iste provident ipsa earum. Optio, culpa, repudiandae.</div>
<div>Quo amet ex obcaecati natus, nesciunt accusamus eius laudantium magni id. Dolorum mollitia ab nam saepe excepturi, sapiente quisquam ducimus, perspiciatis obcaecati modi qui, sit laborum vero vitae cumque sequi!</div>
<div>Repudiandae laborum ducimus totam! Neque aliquam alias necessitatibus praesentium numquam fuga totam inventore quis ab tempore aliquid dolore, similique voluptatem ipsam nisi earum ea quidem dolor, optio quibusdam? Sed, corrupti.</div>
<div>Culpa a quos, explicabo adipisci pariatur impedit obcaecati consectetur aut maxime architecto eos facere ex voluptate provident iste blanditiis sed laboriosam magni aspernatur esse corrupti quasi quod! Officiis corrupti, voluptatibus.</div>
<div>Optio sunt ipsam, et esse libero consequatur maiores illum nihil ad asperiores sed rem soluta sapiente quia nobis voluptatem, velit pariatur sint non aperiam, nostrum. Dolorum officiis, amet tenetur odio?</div>
<div>Culpa dicta in soluta, cum, sapiente natus atque, vitae, laudantium ipsam dolorem obcaecati ad quibusdam. Accusantium consequatur sit odit minima, omnis nihil unde pariatur. Distinctio doloremque earum, deserunt doloribus culpa.</div>
<div>Doloribus nobis, minima animi. Rerum magni hic dicta iste, laborum similique, sed corrupti accusamus ad quam assumenda ab consectetur suscipit nostrum. Sapiente aliquid, voluptatibus eius optio modi tenetur, unde iure.</div>
<div>Impedit, dicta, atque nesciunt quos laboriosam facilis, nihil assumenda officiis omnis reiciendis iste quisquam asperiores eveniet ad corrupti error voluptatum consectetur velit neque. Minima distinctio, corporis expedita eius sapiente cumque?</div>
<div>Repellendus tempora rem corporis ullam soluta est veritatis, itaque! Quo fugit dicta minus obcaecati minima repellendus numquam, ipsam non eligendi porro exercitationem nesciunt vel similique nemo necessitatibus dolorem dolorum id?</div>
<div>Ad obcaecati voluptas nobis veniam explicabo ut atque eaque itaque, magni sed, veritatis totam ea, repellendus in quia iure soluta suscipit aliquam? Adipisci fugit ipsum delectus nisi vitae, veritatis ducimus.</div>
<div>Dolorem inventore facere doloremque quod excepturi. Quo nostrum non quaerat pariatur. Pariatur necessitatibus deleniti ea dolores ut sequi saepe sint nulla. Minima harum explicabo voluptate sunt, adipisci quisquam delectus distinctio.</div>
<div>Neque, numquam libero tempora harum accusantium tempore veniam reprehenderit ea ratione, delectus alias molestias reiciendis eos cumque labore nulla quasi aliquam qui eaque accusamus dolor iste sed veritatis? Maxime, cum!</div>
<div>Reiciendis veritatis recusandae aliquid eos laudantium culpa, consectetur aspernatur voluptate expedita? Explicabo, quisquam! Alias mollitia velit nesciunt, tempore ipsum distinctio, iusto, quidem dolor odio consequatur, ipsa iste. Repellendus veritatis, quas?</div>
<div>Quos omnis repudiandae, corrupti consequuntur culpa. Magnam aperiam, ad accusantium consequuntur. Nemo iure ab temporibus molestias et nesciunt eum excepturi magni, ipsum quae, molestiae eaque reprehenderit voluptatem! Fugit, praesentium, beatae!</div>
<div>Sit officia, quasi veritatis sint inventore odit consequatur iusto et ex sequi nihil quisquam praesentium, quos neque eum. Atque recusandae dolorum illum iusto consectetur dolores maiores blanditiis! Libero, explicabo officiis?</div>
<div>Ratione repudiandae ad officia quas nemo eos molestias quasi, perferendis facere, aspernatur. Aliquid nobis est dolor natus soluta harum veniam enim deserunt sint. Unde corrupti magni nobis, non a, necessitatibus.</div> </div>
<div class="footer"> footer </div>
</div>
I'll go with the flex option while i was waiting for a feed back about it. ...
header,
footer {
background: tomato;
min-height: 15vh;/* any height is fine actually, mind some room for main if small window ... header& footer should not be covering the entire window */
display: flex;/* to dispatch children */
flex-direction: column;/* not in a row ! */
}
main {
background: turquoise;
flex: 1;/* fill up entire space */
overflow: auto;/* if space too small, let me scroll */
display: flex;/* to easy center content */
flex-direction: column;/* lets behave as block container */
}
div {
margin: auto;/* flex children will center on both axis , an easy one !*/
}
body {
max-width: 1024px;/* so it can shrink beloww , else remove the max- prefix */
height: 100vh;/* window's height */
margin: 0 auto;
display: flex;
flex-direction: column;
}
main:hover div:after {
display: block;
content: 'test';
height: 200vh;
}
<header>
<div>
<h1>header</h1>
</div>
</header>
<main>
<div>main, hover me to make me taller and scroll</div>
</main>
<footer>
<div>footer </div>
</footer>
for the display table-layout, you should start from body :
html, body {
height:100%;
margin:0;
}
body {
width:1024px;
margin:auto;
display:table;
}
header,footer,main {
display:table-row;
}
header>div,main>div,footer>div {
display:table-cell;
vertical-align:middle;
}
main {
height:100%;
background:turquoise;
}
footer,header {
height:120px;
background:tomato;
}
<header>
<div>
<h1>header</h1>
</div>
</header>
<main>
<div>main content, i will not scroll, i will push the footer</div>
</main>
<footer>
<div>footer </div>
</footer>

Set image to always be full height in flex column

I have two columns set to 50%, left with text and right with image that should fill whole column vertically. The problem is that when text is a little bigger, there is a gap below the image. Is it possible to always have the image occupy the full height (but in same ratio)? For example, the image could get wider than its column, in that case I could just set overflow hidden.
.flex {
display: flex;
border: 3px solid black;
padding: 10px;
}
.col {
border: 1px dashed #aaa;
}
.left {
padding: 30px;
}
<div class="flex">
<div class="col left">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias eos fugiat deserunt ullam tempore? Aspernatur eligendi dolores explicabo officiis adipisci, incidunt distinctio tempore culpa, esse cumque atque repellendus eius delectus fugit quia odit
ut porro laborum alias. Aliquam et est neque ut, rem ab omnis? Culpa rerum, vel ad magnam iusto explicabo at consequatur deserunt quo repellendus. Sequi nulla nemo a magni voluptates. Nemo mollitia, ut ex temporibus voluptatem incidunt nostrum quo,
quod reprehenderit omnis! Sequi nulla nemo a magni voluptates.
</p>
</div>
<div class="col right">
<img src="http://placehold.it/550x250" alt="">
</div>
</div>
You have to set following CSS properties to image
height:100%;
width:auto;
.flex {
display: flex;
border: 3px solid black;
padding: 10px;
}
.col {
border: 1px dashed #aaa;
overflow-x: hidden;
}
.left {
padding: 30px;
}
.right img {
height: 100%;
width: auto;
}
<div class="flex">
<div class="col left">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias eos fugiat deserunt ullam tempore? Aspernatur eligendi dolores explicabo officiis adipisci, incidunt distinctio tempore culpa, esse cumque atque repellendus eius delectus fugit quia odit
ut porro laborum alias. Aliquam et est neque ut, rem ab omnis? Culpa rerum, vel ad magnam iusto explicabo at consequatur deserunt quo repellendus. Sequi nulla nemo a magni voluptates. Nemo mollitia, ut ex temporibus voluptatem incidunt nostrum quo,
quod reprehenderit omnis! Sequi nulla nemo a magni voluptates.
</p>
</div>
<div class="col right">
<img src="http://placehold.it/550x250" alt="">
</div>
</div>
The quickest way to get the image to fill the vertical height of the container would be to make the parent a flex container. This automatically applies align-items: stretch to the children (in this case, the image).
.right { display: flex; }
From that point, you could use various methods to set the correct aspect ratio to the image. You could use percentage height, if you have defined heights on the parent / ancestors.
Or you could use the object-fit property.
.flex {
display: flex;
border: 3px solid black;
padding: 10px;
}
.col {
border: 1px dashed #aaa;
}
.left {
padding: 30px;
}
.right {
display: flex;
}
img {
object-fit: cover;
}
<div class="flex">
<div class="col left">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias eos fugiat deserunt ullam tempore? Aspernatur eligendi dolores explicabo officiis adipisci, incidunt distinctio tempore culpa, esse cumque atque repellendus eius delectus fugit quia odit
ut porro laborum alias. Aliquam et est neque ut, rem ab omnis? Culpa rerum, vel ad magnam iusto explicabo at consequatur deserunt quo repellendus. Sequi nulla nemo a magni voluptates. Nemo mollitia, ut ex temporibus voluptatem incidunt nostrum quo,
quod reprehenderit omnis! Sequi nulla nemo a magni voluptates.
</p>
</div>
<div class="col right">
<img src="http://placehold.it/550x250" alt="">
</div>
</div>
Note that object-fit is not natively supported in Internet Explorer. For more details and a workaround see: Why isn't object-fit working in flexbox?

adjust margin in just 1 div [duplicate]

This question already has answers here:
Margin on child element moves parent element
(18 answers)
Closed 6 years ago.
Well, now I've this problem, I want to adjust just the margin on the "c2" but when I set it to X, it changes the "c1" div margin :S
Here's the code I'm using:
<header>
<div class="jumbotron">
<center><h1>Bienvenidos a JVasconcelos.me</h1></center>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-12 col-centered">
<div class="c1">
<div class="c2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis inventore illum quaerat laboriosam eos, vel sed suscipit cumque laborum est animi aliquid tempora iusto beatae quam quisquam porro dolore! Ullam tenetur doloribus ducimus, totam voluptatum, deleniti vero voluptatem eius architecto velit neque voluptas aliquam quidem sed eveniet! Nobis ex eos iste dolorum tempora doloremque non deleniti, aperiam quibusdam corrupti officia consequatur, impedit. Exercitationem debitis iste voluptatum, illo nulla iure culpa ex fugit, aliquid dolorem excepturi, impedit voluptates quae quidem error earum natus, provident eum vitae. Tempore ducimus laborum voluptates, qui aspernatur odit dolorum modi quas cupiditate unde quam earum amet!
</p>
</div>
</div>
</div>
</div>
</div>
CSS
div.c1 { height: 100vh; background: #417ba1; margin-top: -30px; padding: 0px 30px; }
div.c2 { height: 90%; background: #fff; margin-top: 0px; padding: 60px 30px; }
.jumbotron { background: url("../img/header_bg.png") no-repeat; height: 100%; }
Ah. You're looking for
.c1 {
overflow: auto; // or hidden or overlay
}
This behavior is due to the collapsing margins part of the box model spec. Putting overflow: auto|hidden|overlay on the parent will establish a new block formatting context and stop the margins from collapsing.
This is because the border of the c1 and c2 are collapsing. You have to hide the overflow (with overflow: hidden or any overflow different that default, which is visible) of the container to avoid that the c1 also get the margin of c2.
div.c1 { height: 100vh; background: #417ba1; overflow: hidden; margin-top: -30px; padding: 0px 30px; }
div.c2 { height: 90%; background: #fff; margin-top: 20px; padding: 60px 30px; }
.jumbotron { background: url("../img/header_bg.png") no-repeat; height: 100%; }
<header>
<div class="jumbotron">
<center><h1>Bienvenidos a JVasconcelos.me</h1></center>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-12 col-centered">
<div class="c1">
<div class="c2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis inventore illum quaerat laboriosam eos, vel sed suscipit cumque laborum est animi aliquid tempora iusto beatae quam quisquam porro dolore! Ullam tenetur doloribus ducimus, totam voluptatum, deleniti vero voluptatem eius architecto velit neque voluptas aliquam quidem sed eveniet! Nobis ex eos iste dolorum tempora doloremque non deleniti, aperiam quibusdam corrupti officia consequatur, impedit. Exercitationem debitis iste voluptatum, illo nulla iure culpa ex fugit, aliquid dolorem excepturi, impedit voluptates quae quidem error earum natus, provident eum vitae. Tempore ducimus laborum voluptates, qui aspernatur odit dolorum modi quas cupiditate unde quam earum amet!
</p>
</div>
</div>
</div>
</div>
</div>
I assume you mean when you change the margin-top on the div.c2 your div.c1 also shifts down. This is due to the default definition of a div+div construct.
To achieve what you want you will need to create the following extra css definition on your div.c1:
display: inline-block;
Have a look at this codepen: http://codepen.io/anon/pen/beNjbW
Difference of or greater margin of c1 or c2 will be rendered due to collapsible margins.
In this case your total distance will be 0 (they cancel each other):
div.c1 {
margin-top: -30px;
}
div.c2 {
margin-top: 30px;
}
In this case your distance will be 10px from the top:
div.c1 {
margin-top: -30px;
}
div.c2 {
margin-top: 40px;
}
One of top margins can be omitted in this case. You can control the distance to header by adjusting margin-top of either one
codePen example

How do I make a flexible width on an element with absolute position?

The width of .in is automatically the width of .three. The amount of text in .in is flexible with each list element. I need the width of .in to adjust according to the amount of text in it.
min-width will keep it from being too small, but there is extra space when there is only a few words. width:auto and height:auto don't change anything. Turning display to inline-block or table doesn't work either, maybe because it's position:absolute?
Right now it's the same width of it's parent and really tall, which looks weird.
<ul>
<li>
<div>
<p class="one">One</p>
<p class="two">Two</p>
<a class="three">Three<p class="in">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p></a>
<p class="four">Four</p>
<p class="five">Five</p>
</div>
</li>
<li>
<div>
<p class="one">One</p>
<p class="two">Two</p>
<a class="three">Three<p class="in">Lorem ipsum</p></a>
<p class="four">Four</p>
<p class="five">Five</p>
</div>
</li>
</ul>
.in is positioned relative to .three. It hovers to the bottom right.
.three{
position:relative;
width:80px;
}
.in{
background-color:white;
border-radius:10px 30px 30px 30px;
left:35px;
max-width:400px;
padding:30px;
position:absolute;
top:5px;
z-index:10;
}
Is that you wanted?
.three {
position: relative;
display: block;
}
.in {
background-color: white;
border-radius: 10px 30px 30px 30px;
left: 35px;
padding: 0 30px;
position: absolute;
top: 0;
z-index: 10;
margin: 0;
}
<ul>
<li>
<div>
<p class="one">One</p>
<p class="two">Two</p>
<a class="three" href="#">Three<p class="in">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p></a>
<p class="four">Four</p>
<p class="five">Five</p>
</div>
</li>
<li>
<div>
<p class="one">One</p>
<p class="two">Two</p>
<a class="three" href="#">Three<p class="in">Lorem ipsum</p></a>
<p class="four">Four</p>
<p class="five">Five</p>
</div>
</li>
</ul>
Why don't you just change your max-width to width:500px; or something like that then it should just expand and show all the text.
Updated JSFiddle
.in{
background-color:white;
border-radius:10px 30px 30px 30px;
left:35px;
width: 500px;/<!--This is what you have to change-->
padding:30px;
position:absolute;
top:5px;
z-index:10;
}

Can I make height 100% work like width 100%?

Fiddle
I have two <div>s floated left inside a <section>. I am looking for the simplest way to get whichever <div> is shorter, in this case <div id="one"> to stretch its height to match the other (<div id="two">). In the fiddle, you will see that <div id="one"> has a gray background, which I want to continue down to the bottom of the <section>. Any workarounds or whatever to get this done is great. But I don't want to use javascript to do this. Thanks.
HTML:
<section>
<div id="one"><p>Lorem</p></div>
<div id="two">
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore</p>
</div>
<div class="clear"></div>
</section>
CSS:
section {
width: 80%;
margin: 0 auto;
border: 1px solid #ccc;
border-radius: 5px;
}
#one, #two {
float: left;
width: 50%;
}
#one {
background: rgb(230,230,230);
}
.clear {
clear: both;
}
load jquery and add the following javascript
$(document).ready( function() {
var x = $("#one").css('height');
var y = $("#two").css('height');
if(x > y) {
$("#two").css('height', x);
} else {
$("#one").css('height', y);
}
});
but incase you are allergic to JavaScript ... and would accept CSS3 you could try
section {
display: flex;
width: 80%;
margin: 0 auto;
border: 1px solid #ccc;
border-radius: 5px;
}
#one, #two {
display: flex;
width: 50%;
display: table-cell;
}
Here is a pure HTML and CSS solution for you. It uses a div with a class of "inner" to wrap your divs you want to match up. Some CSS is also added to make it behave like you want it to.
jsFiddle solution - pure HTML and CSS
HTML code:
<section>
<div class="inner">
<div id="one">
<p>Lorem</p>
</div>
<div id="two">
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore
veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia
consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque
porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,
adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore</p>
</div>
</div>
<div class="clear"></div>
You can hack around the padding on the p in the #one div, but this will throw your text off in this div. I'm not sure how relevant it is with aligning to the other text, but it may help you out.
#one p {
padding: 9em;
}