How to make this 2 column table without using tables? - html

http://jsfiddle.net/pkLMC/
the left column should shrink to fit, and the right column should take up the remainder of the width of the page. It needs to work with IE7 as well
image of issue
<style>
table
{
width:100%;
border:1px solid black;
}
td
{
vertical-align:top;
border:1px solid green;
background-color:orange;
}
.left
{
/* trim the column to the minimum necessary width required to avoid overflow */
width:1px;
}
.long
{
/* this layout works whether the content of the right column wraps or not */
/* display:none; */
}
</style>
<table>
<tr><td class="left">ABC</td><td>Lorem ipsum dolor</td></tr>
<tr><td class="left">ABCDE</td><td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td></tr>
<tr class="long"><td class="left">ABCDEFG</td><td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</td></tr>
<tr class="long"><td class="left">ABCDEFGHI</td><td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</td></tr>
<tr class="long"><td class="left">ABCDEFGHIJK</td><td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</td></tr>
</table>

The data you present in your example is tabular in nature in that it has both rows and columns. Css without HTML tables is good for formatting stuff in columns (like a newspaper). Once you have both rows and columns with variable width columns (like your data), tables (/table, /tr, /td, etc.) is the way to go.
You might want to stripe your rows. Here is an example: http://jsfiddle.net/peavU/

Something to keep in mind is that using tables for layout is not a bad thing at all IF the information you're presenting is tabular in nature.
Using tables to arrange non-tabular data isn't good, but that doesn't mean that tables don't have their place.
On preview... what #DwB said.

A definition list <dl> is perfect for the type of layout you have on your fiddle.
http://www.maxdesign.com.au/articles/definition/

Have you tried using div tags instead? They are more organized, efficient, and can adjust to multiple screen sizes

I agree with both #DwB and #Diodeus. Means, if you have really tabular data, the best you can do is to use tables. But, if your list is actually a list of definitions, then it makes sense to convert to <dl> like in the example:
HTML
<dl>
<dt>THIS IS THE TITLE</dt>
<dd>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</dd>
<dt>THIS IS ANOTHER TITLE</dt>
<dd>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</dd>
</dl>
CSS
dl {
width: 100%;
background: Orange;
margin: 0;
padding: 0;
}
dt {
width: 10em;
clear: left;
float: left;
padding: 1em;
border-top: 1px solid #fff;
}
dd {
margin-left: 12em;
padding: 1em;
border-left: 1px solid #fff;
border-top: 1px solid #fff;
}

I can get a bit crazy using lists, but here is my two cents...with a jsFiddle example: Table like layout using lists
The code should resize and the text won't wrap, utilizing the "text-overflow: ellipsis;" css rule.
HTML:
<ul>
<!-- "table" header" -->
<li class="col1 th">Column 1 header</li>
<li class="col2 th">Column 2 header</li>
<!-- "table" rows -->
<li class="col1">data</li>
<li class="col2">data</li>
<li class="col1">data</li>
<li class="col2">data</li>
<li class="col1">data</li>
<li class="col2">data</li>
<li class="col1">data</li>
<li class="col2">data</li>
<li class="col1">data</li>
<li class="col2">data</li>
CSS:
* {
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
ul {
border: 1px solid #333;
list-style-type: none;
zoom: 1; /* For IE 6/7 (trigger hasLayout) */
}
ul:after {
content:"";
display: table;
clear: both;
}
.col1, .col2{
float: left;
text-align: left;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
padding: .25em;
white-space: nowrap;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.col1 {
clear: left;
width: 30%;
}
.col2{
width: 70%;
}
.th {
font-weight: bold;
text-align: center;
}
Hopefully that helps!

Related

CSS - Side-by-Side Divs Inherit Height?

JSFiddle
Trying to learn to manually set up 12-Column grids. I'd like my grid_8 and grid_4 to expand to be the same height. They're set to inherit height, as is their parent ("container"), so my thought is that they should all match the height of the outermost div, "main_content", which I think I have set up to dynamically change its height.
The container and grid_8 divs seem to match the height properly, but why not my grid_4 div? If I manually fix the height of the main_content div, than they all expand in height properly, but why does it not work in this case?
Any help as to what I'm not understanding would be appreciated.
HTML:
<body>
<div class="main_content">
<div class="container">
<div class="grid_8">
<p>
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
</div>
<div class="grid_4">
<p>
This should be the same height as the div to my left.
</p>
</div>
</div>
</div>
</body>
CSS:
body{
margin: 0px;
box-sizing: border-box;
}
.container {
width: 964px; /* Account for borders */
height: inherit;
margin: 0 auto;
overflow: hidden;
border: 1px solid red;
}
div[class^="grid"]{
float: left;
margin: 0 auto;
height: inherit;
}
.grid_4 {
width: 320px;
border: 1px solid blue;
}
.grid_8 {
width: 640px;
border: 1px solid green;
}
.main_content{
overflow: hidden;
/* height: 600px; */
border: 1px solid black;
}
JSFiddle
What I can see is you have not provided any height to main_content, hence grid have also inherited no height at all.
so the height they are getting is only because of the content present inside them.
and when you are setting the value manually(600px) then the container and grids are inheriting that much value and are getting properly arranged.

100% width split into 3* 33% divs

I've been trying to use 3 divs like a table, so to make 3 columns I thought I#d make 3 33% divs. That works fine and they fill the page up, but as soon as I want to add padding to make the text move off the border, the 3rd div moves into the next line.
Any suggestions to keep padding but all 3 in one row would be appreciated.
Code:
CSS:
.container {
padding-top: 53px;
width:100%;
}
.table1{
border-style: solid;
border-width: 2px;
float: left;
width: 33.3%;
text-align: justify;
padding-left: 3px;
padding-right: 3px;
background-color: gray;
}
.table2{
border-style: solid;
border-width: 2px;
border-left: 0px;
border-right: 0px;
float: left;
width: 33.3%;
text-align: justify;
padding-left: 3px;
padding-right: 3px;
}
.table3{
border-style: solid;
border-width: 2px;
float: left;
width: 33.3%;
text-align: justify;
padding-left: 3px;
padding-right: 3px;
}
HTML:
<div class="container">
<div class="table1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table3">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
You could add box-sizing: border-box to the elements so that the padding/border is included in its height/width calculations:
.table1, .table2, .table3 {
box-sizing: border-box;
}
I'd suggest adding a common class to the tables as well:
Example Here
.table {
width: 33.33%;
box-sizing: border-box;
}
Use display: table and table-layout: fixed for the container and display: table-cell for columns:
.container {
display: table;
table-layout: fixed; /* For equal column widths regardless of their number. */
width: 100%;
}
.container > DIV {
display: table-cell;
}
Unlike floats, this method is guaranteedly free from any gaps between columns and on each side of the container.
Unlike Flexbox (IE10+), it works in IE8+.
Alternately, you can modify your code a little and make use of CSS calc() function like below:
width: calc(33.3% - 10px);
Where each div width is 33.3% - ( 3px padding left + 3px padding right + 2px border left width + 2px border right width) - because padding and borders add values to the element width -.
This for .table1 and table3, but for the middle .table2 div there's no border-right nor border-left width values so it is only 6px instead of 10px
Also you have ltos of redundant code so I simplified it a little JS Fiddle
.container {
padding-top: 53px;
width:100%;
}
.table1, .table2, .table3{
border:2px solid;
float: left;
padding: 0 3px;
width: calc(33.3% - 10px);
text-align: justify;
}
.table1{
background-color: gray;
}
.table2{
border:none;
border-top:2px solid;
border-bottom:2px solid;
width: calc(33.3% - 6px);
}
<div class="container">
<div class="table1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table3">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
Flexbox works: do the following:
Apply reset:
html,
body {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0;
outline: none;
}
Make .container a flex container:
.container {
padding-top: 53px;
width: 100%;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
}
Apply this to each child (e.g. .table1, etc...):
flex: 1 0 auto;
Floats don't work in flex flow environments, so you can delete all float: left. added bonus is your columns match in height as well as width. If you wanted gutters (space between the columns like a newspaper), replace flex-start with space-between and decrease width if necessary.
html,
body {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0;
outline: none;
}
.container {
padding-top: 53px;
width: 100%;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
}
.table1 {
border-style: solid;
border-width: 2px;
text-align: justify;
width: 33.3%;
padding-left: 3px;
padding-right: 3px;
background-color: gray;
flex: 1 0 auto;
}
.table2 {
border-style: solid;
border-width: 2px;
border-left: 0px;
border-right: 0px;
text-align: justify;
width: 33.3%;
padding-left: 3px;
padding-right: 3px;
flex: 1 0 auto;
}
.table3 {
border-style: solid;
border-width: 2px;
text-align: justify;
width: 33.3%;
padding-left: 3px;
padding-right: 53px;
flex: 1 0 auto;
}
<p>I have added an extra 50px to .table3 to demonstrate that all columns maintain a 33.33% width.</p>
<div class="container">
<div class="table1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="table3">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>

-webkit- textarea losing top & bottom padding on vertical scrollbar

I have a textarea element with fixed width & height and no resize and when the vertical scrollbar appears the padding (top & bottom) of the element is ignored.
Here is a plnkr demo: http://plnkr.co/edit/jOeYXqkOZk3FCT24BRrk?p=preview
This happens only with Chrome (tested on Chromium, Linux version).
Here is my styling for the textarea element:
textarea{
background-color: #1c1b1b;
border-bottom: 3px solid #343434;
border-radius: 4px;
color: #fff;
display: block;
height: 165px;
margin-bottom: 21px;
padding: 10px;
resize: none;
width: 90%;
}
*One solution would be to wrap the textarea element inside a div with that specific padding, but then the scrollbar will not overlap that padding and will look kinda strange.
Edit: ok, maybe it won't look as strange as I thought, but I just wonder if there is a more elegant fix, within css maybe.
I've tried to think of a workaround, depending on your own hint. You've got it right, but didn't implement it yet. :) I just coded your idea. What I did was to enclose within a wrapper, and setting before and after pseudo elements to just hide the top and bottom parts. I hope that would solve your issue.
It would also run perfectly in Chrome, Firefox as well as in IE.
.container {
width: 90%;
position: relative;
}
textarea {
background-color: #1c1b1b;
border:0;
border-radius: 4px;
color: #fff;
display: block;
height: 165px;
margin-bottom: 21px;
padding: 10px;
resize: none;
width: 100%;
border-radius: 4px;
}
.container:before, .container:after {
content:'';
display: block;
height: 10px;
background: #1c1b1b;
position: absolute;
left: 4px;
right: 18px;
}
.container:before {
top: 0px;
}
.container:after {
bottom: 0px;
}
<div class="container">
<textarea>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</textarea>
</div>

2 divs on same line won't extend all the way to include text

I have two divs I have placed next to each other inside a content-container div, one of them includes a video and some description text and the other includes a scrollbar of random text. However, as you can see in this picture ( http://gyazo.com/1a5b3e559c1f4294b8c05b6c74fc677d ), the content-container doesn't include the description like I wanted (thus making the rounded div content-container not cover it). I have tried to fix it, but I haven't had much luck. Here is a breakdown of my code:
I'll show the CSS first:
#content-container3
{
margin-top: 10px;
width: 900px;
repeat-y 100% 0;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #575757;
background: #DBDBDB;
}
#content
{
margin-top: 10px;
padding: 5px;
padding-top: 0px;
float: left;
}
#scroll {
height: 358px;
border: 1px solid #999;
width: 239px;
overflow: auto;
margin-top: 10px;
padding: 2px;
}
And now onto the HTML
<div id="content-container3">
<div id="content">
<video id="player_a" class="projekktor" poster="intro.png" title="1v1LB Player" style="background: black;" width="640" height="360" controls>
<source src="unorthxdox.mp4" type="video/mp4" />
</video> <h2 style="padding-top: 10px;">
Unorthxdox vs CaLeB XII</h2>
Player's Profile | Editor's Profile <br />
Click here to view comment(s) on the game.
</div>
<div id="scroll">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
From the code I have posted, it should be working. I have tried messing with the float and the width and other things such as that and I haven't been able to find a solution. I'm not the best with HTML/CSS, but I would like to be able to at least fix this.
Adding float: left; into all three css rules helps.
(But don't forget to clear it after. And anyway, I would take risk and advise you not to use floats. Your markup, you can achieve it by removing float: left and adding display: inline-block; to #content and #scroll.)

Last of DIVs that fits the container height

I've two (or more) DIVs inside a list item and I'm not able to make the last one to fit the remaining height of its container.
This is the code:
CSS
div{margin: 5px;}
ul{
height: 300px;/*it's calculated via js*/
width: 250px;/*it's calculated via js*/
padding: 0;/*don't change it*/
margin: 0;/*don't change it*/
background-color: #F5EBD6;
border: 4px solid orange;
}
li{
list-style-type: none;
background-color: #E0E5F5;
border: 2px solid blue;
}
.item-title{
background-color: #EDF5E0;
border: 2px solid green;
}
.item-description{
background-color: #FDF1FB;
border: 2px solid fuchsia;
}
.item-description>div{
background-color:rgba(252,255,170,0.3);
}​
HTML
<ul>
<li>
<div class="item-title">Title</div>
<div class="item-description">
<div style="margin: 0px; padding: 0px; border: 0px;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</li>
​
Here's the Fiddle.
I'd like that the .item-description div (fuchsia bordered div in the Fiddle) will stay inside listItem (the orange bordered element).
The div inside the description, the actual text container, should not be modified in its height.
Here's the Fiddle that shows how it should look like.
On the right the result I'd like to reach
I'd like to solve the problem using css/css3, not js and without changing the HTML, if possible.
Can you help me?
Change the UL css like below,
ul {
background-color: #F5EBD6;
border: 4px solid orange;
float: left;
margin: 0;
min-height: 300px;
padding: 0;
width: 250px;
}
it will works.
Adding
overflow-y:scroll;
to .item-description
might put all the content inside the div.AM not sure this is what you are expecting
http://jsfiddle.net/Pdaj8/2/