I have a page with three columns. They're all fluid:
#LeftColumn
{
display:table-cell;
float:left;
padding-left:0;
padding-right:16%;
padding-top:0;
padding-bottom:1%;
margin-right:1%;
margin-left:0;
margin-bottom:0;
margin-top:0;
position:static;
}
#RightColumn
{
display:table-cell;
float:right;
padding-right:0;
padding-left:16%;
padding-top:0;
padding-bottom:1%;
margin-left:1%;
margin-right:0;
margin-bottom:0;
margin-top:0;
}
#Content
{
display:table-cell;
width:auto;
}
In the page they are represented as follows:
<div id="LeftColumn">
</div>
<div id="RightColumn">
</div>
<div id="Content">
<!-- Stuff goes here -->
</div>
I've created a few pages in my project with this layout, and it worked rather well. However, there's a problem: The middle column only expands when I put text in it. Thus, when I place something such as a horizontal ruler in it, it's only as wide as the previous and following paragraphs. I want the center div (#Content) to be as wide as the space between the left and right columns (#LeftColumn, #RightColumn) Is this possible?
try giving #Content display: block. and give all three divs the same height.
that will expand to fill the empty space:
http://jsfiddle.net/HMS2s/
It helps to establish a container of the objects, so their percentiles have are based off a solid, but I imagine you'll handle the media queries. The padding shouldn't be used to create width for the middle column because it will take up space which is what I believe you were trying to do? If you want equal height columns there is a really long article on this that you should check out here.
Example of this CSS
#container{
width:80%;
float:left;
}
#leftcolumn{
float: left;
width: 33%;
background-color:green;
padding: 0 0 1% 0;
margin: 0 1% 0 0;
display: table-cell;
}
#middlecolumn{
overflow:hidden;
background-color:blue;
padding: 0 1% 1% 1%;
}
* html #middlecolumn{float:left}
* html #middlecolumn #content{width:100%;}
#rightcolumn{
float:right;
width: 33%;
background-color:red;
position:relative;
padding: 0 0 1% 0;
margin: 0 0 0 1%;
display: table-cell;
}
Delete display:table-cell; from #Content and add overflow:hidden;
Something like the following maybe?
CSS
#LeftColumn
{
display:table-cell;
float:left;
padding-left:0;
padding-right:16%;
padding-top:0;
padding-bottom:1%;
margin-right:1%;
margin-left:0;
margin-bottom:0;
margin-top:0;
position:static;
}
#RightColumn
{
display:table-cell;
float:right;
padding-right:0;
padding-left:16%;
padding-top:0;
padding-bottom:1%;
margin-left:1%;
margin-right:0;
margin-bottom:0;
margin-top:0;
}
#Content
{
overflow: hidden;
}
HTML
<div id="LeftColumn">
</div>
<div id="RightColumn">
</div>
<div id="Content" class="Content">
<!-- Stuff goes here -->
</div>
Example
Related
I am having extreme difficulty organizing two divs.
I have a footer, which includes two paragraphs. I want paragraph 1 hugging the left border of the footer div, and I want paragraph 2 hugging the right border of the footer div, AND these paragraphs must be on the same line.
My problem is that my divs are behaving oddly.
I have tried floating and giving widths but nothing seems to work, the paragraphs seem to keep piling on top of eachother.
Does anybody know how to resolve this? I just want to know how to write 2 paragraphs out on the same line hugging opposite borders.
HTML:
<div id='container'>
<div id='footer'>
<div id="errors">
<p>paragraph 1</p>
</div>
<div id="other">
<p>paragraph 2</p>
</div>
</div>
</div>
CSS:
#container
{
width:90%;
margin:auto;
background-color:#F6F4F1;
border: 5px solid #00b4b4;
padding:0;
border-radius: 25px;
}
#footer
{
width:100%;
bottom:0;
color:#838B8B;
font-family:verdana;
}
#errors
{
margin-left:4.5%;
text-align:left;
color:red;
}
#other
{
text-align:right;
margin-right:3%;
display:inline-block;
}
JS FIDDLE which shows how my code is behaving oddly.
I have made changes to your fiddle https://jsfiddle.net/4vuywmn2/1/
You must float the errors div to the left and the other div to right and you must clear after the container around them closes.
To understand why you need to clear I suggest you read this answer
Is this what You want :
#container
{
width:90%;
margin:auto;
background-color:#F6F4F1;
border: 5px solid #00b4b4;
padding:0;
border-radius: 25px;
}
#footer
{
width:100%;
bottom:0;
color:#838B8B;
font-family:verdana;
}
#errors
{
margin-left:4.5%;
text-align:left;
color:red;
display:inline-block;
float:left;
}
#other
{
text-align:right;
margin-right:3%;
display:inline-block;
float:right;
}
<div id="container">
<div id='footer'>
<div id="errors">
<p>Paragraph 1</p>
</div>
<div id="other">
<p>Paragraph 2</p>
</div>
<div style="clear:both;"></div>
</div>
</div>
You have to add display:inline-block; for error class, and using float : left for error, and right for other. And, on end, after other, You have to add one more div with clear:both;, how above div float will be cleared.
Try float and position attributes like this...
#container
{
width:90%;
margin:auto;
background-color:#F6F4F1;
border: 5px solid #00b4b4;
padding:0;
border-radius: 25px;
}
#footer
{
width:100%;
bottom:0;
color:#838B8B;
font-family:verdana;
}
#errors
{
margin-left:4.5%;
text-align:left;
color:red;
float:left;
position:absolute;
left:0px;
}
#other
{
text-align:right;
margin-right:3%;
display:inline-block;
float:right;
position:absolute;
right:0px;
}
try this mate, is this what you want:
#footer
{
height: 100px;
width:100%;
bottom:0;
color:#838B8B;
font-family:verdana;
}
#errors
{
float: left;
margin-left:4.5%;
text-align:left;
color:red;
}
#other
{
float: right;
text-align:right;
margin-right:3%;
display:inline-block;
}
https://jsfiddle.net/4vuywmn2/5/
I am playing around with using Divs and CSS instead of tables and I am having some problems with my code/CSS. I am trying to set this up so I have 3 columns next to eachother in a container that is centered to the page which has the text aligned to the bottom so the text is around the same height as the bottom of the image I am using in the center column. I have been unable to achieve this and I have a new found respect for UI guys. My code and CSS are as follows. Any guidance would be helpful :)
body {
}
#Container
{
border:1px solid #dddddd;
padding:40px 94px 40px 94px;
background:#ffffff;
width:55%;
height:auto;
border-radius:0px;
margin-left:auto;
margin-right:auto;
position:relative;
}
#Address
{
border:1px solid #dddddd;
position:relative;
text-align:left;
width: 33%;
}
#Phone
{
border:1px solid #000000;
position:relative;
text-align:right;
width: 33%;
}
#Logo
{
border:1px solid #4cff00;
position:relative;
float: left;
width: 33%;
}
HTML
<div id="Container">
<div id="Address">123 Testing Street</div>
<div id="Phone">(ccc) 223-3323</div>
<div id="Logo"><img src="http://upload.wikimedia.org/wikipedia/en/0/0c/ITunes_11_Logo.png" /></div>
</div></blockquote>
see the fiddle here , This is not 100% everything you asked for, but it is a big start! You have the appearance of a table while only using div's. I am not going to finish every little detail for you, but this should get you going, it is almost complete.
#Container{
border:1px solid #dddddd;
padding:5px;
background:#bbb;
width:55%;
margin: 0px auto;
position:relative;
height:200px;
}
.cell{
display:inline-block;
width:32%;
height:100%;
border:1px solid #000;
position:relative;
vertical-align:bottom;
line-height:370px;}
<div id="Container">
<div id="Address" class="cell">123 Testing Street</div>
<div id="Phone" class="cell">(ccc) 223-3323</div>
<div id="Logo" class="cell">
<img src="http://upload.wikimedia.org/wikipedia/en/0/0c/ITunes_11_Logo.png" style="height:50px;" />
</div>
</div>
I simplified your css a bit. See if this is what you're looking for.
#Container{
margin:0 auto;
width:500px;
background:gray;
}
#Address, #Phone, #Logo{
float:left;
width:33%;
height:256px;
line-height:512px;
}
http://jsfiddle.net/39M9L/1/
Part of the problem you're going to have with aligning to the image is there is white space around the logo, so to get the text to align to the edge of the logo, you're going to have to tweak the numbers a bit, rather than rely on the image height.
You can add a span within a div, and use margin-top to make it in the bottom of the div.
CSS:
#Container > div {
min-height: 52px;
float: left;
text-align: center;
}
#Container > div > span {
display: inline-block;
margin-top: 35px;
}
Take a look: [JSFIDDLE] (http://jsfiddle.net/blck/txXE2/)
i want to set .span4(image) and .span8(green box) to the bottom of .row (grey box)
.row should get the size automatic because .span8 has a random height.
what i want is this result:
what i get is this:
example 1
here is .span8 not on bottom of .row but .row has a automatic height
http://jsfiddle.net/39znd/
example 2
here is .span8 on bottom of .row but .span8 is not inside of .row as you can see on post 2 and 3
http://jsfiddle.net/HZu82/
on example 2 i added to .span8 blockquote -> position:absolute;
does anyone have a hint for me?
You can use display:table;on the wrapper and display:table-cell;, vertical-align:bottom;
for your issue see this demo :
FIDDLE
HTML :
<div id="container">
<div class="table">
<div class="row clearfix">
<div class="span4">
<img src="http://lorempixel.com/290/270/people/9/" />
</div>
<div class="span8_wrap">
<div class="span8">
<blockquote class="bubble1-left">
<p>This is a blockquote</p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
CSS :
#container{
width:900px; /* TOTAL WIDTH */
margin:0 auto;
padding:0 40px;
position:relative
}
.table{
display:table;
}
.row{
display:table-row;
margin:0 0 20px 0;
min-height:270px;
background:grey;
}
.clearfix:before,.clearfix:after{content:'\0020';display:block;overflow:hidden;visibility:hidden;width:0;height:0}
.clearfix:after{clear:both}
.clearfix{zoom:1}
.span4{
display:table-cell;
vertical-align:bottom;
width:300px; /* IMG BOX */
background:grey;
}
.span4 img{
display:block;
}
.span8_wrap{
display:table-cell;
vertical-align:bottom;
}
.span8{
padding-bottom:30px;
width:600px; /* TEXT BOX */
background:green;
}
blockquote{margin:0 0 30px 0}
blockquote p{margin:0;font-size:1.25em}
.bubble1-left{
position:relative;
padding:20px;
border:3px solid #000;
text-align:center;
color:#000;
background:#fff;
-webkit-border-radius:20px;
-moz-border-radius:20px;
border-radius:20px;
}
To have empty space above the green div try next things:
Insert some div to this empty place and let the green div have something like 100px height, and the div above 100% height.
Use next styles for green div: position: absolute; left: 0px; bottom: 0px; right: 0px;
I have some problem with my layout. It looks good on my computer when I zoom to 100%. But when I zoom in or out the layout breaks. I tried several ways to wrap the layout but it didn't work so far. Since I need the layout to be responsive, any help is appreciated.
html:
<body>
<div class="low_wrapper">
<div id="intro" class="category">
<p><span class="category_description"><h1>Intro</h1></span></p>
<div class="low_info_header" >head</div>
<div class="low_info_element_big"></div>
<div class="low_info_element_big"></div>
<div class="low_info_header" >head</div>
</div>
<div id="women" class="category">
<h1>Women</h1>
<div class="low_info_header" >head</div>
<div class="low_info_element_big"></div>
<div class="low_info_element_big"></div>
<div class="low_info_header" >head</div>
</div>
</div>
</body>
css:
body{
margin: 0 0 0 0 ;
}
.category h1{
float:left;
width:940px;
font-family:'Open Sans';
}
.low_wrapper{
position:absolute;
margin-left:30px;
margin-top:30px;
position:absolute;
}
#low_info{
margin: 0 0 0px 33px;
width:940px;
background-color: #ccc;
float:left;
}
.low_info_header{
width:940px;
height:120px;
background-color:#FF0A83;
float:left;
position:relative;
}
.low_info_element_big{
height:400px;
width:460px;
background-color:#FF0A83;
margin-top:10px;
margin-right:20px;
margin-bottom:10px;
float:left;
position:relative;
}
http://jsfiddle.net/MsUTp/1/
In your .css you are giving your elements specfic sizes with px. If you want your layout to resize with your screen you should apply size to your elements using % (i.e a percent of the screen size). This way when your screen size changes, your elements will resize relative to it keeping your layout the same.
Try this
body {
margin: 0 0 0 0 ;
}
.category h1 {
width:940px;
font-family:'Open Sans';
}
.low_wrapper {
position:absolute;
margin-left:30px;
margin-top:30px;
position:absolute;
}
#low_info {
margin: 0 0 0px 33px;
width:940px;
background-color: #ccc;
float:left;
}
.low_info_header {
width:100%;
height:120px;
background-color:#FF0A83;
position:relative;
}
.low_info_element_big {
height:400px;
width:460px;
background-color:#FF0A83;
margin-top:10px;
margin-right:20px;
margin-bottom:10px;
position:relative;
}
I'd add in a .wrapper class and change .low_wrapper { position:relative} instead of absolute
.wrapper {
width:960px;
}
.low_wrapper {
position:relative;
margin-left:30px;
margin-top:30px;
}
see example: http://jsfiddle.net/MsUTp/2/
Got problem with divs..
HTML
<div id="site-menu">menu1
<br>menu2
<br>menu3
<br>menu4
<br>menu5
<br>menu6
<br>
</div>
<div id="site-content">
<div class="site-content">
<div id="site-content-left">left</div>
<div id="site-content-right">right</div>
<div class="clear"></div>
</div>
</div>
CSS
.site-content {
background:pink;
}
#site-content {
background:red;
margin-left:250px;
}
#site-content-left {
background:orange;
float:left;
}
#site-content-right {
margin:5px 0 5px 0;
background:blue;
}
#site-menu {
float:left;
width: 250px;
padding: 20px 0;
overflow:hidden;
background:grey;
}
.clear {
clear:both
}
There is gap after clear both. The gap is big as menu div height (there is something with menu div).. Any solution please?
jsFiddle.
There are basically two way you can avoid big gap..
1) Instead of clear:both use clear:right
OR
2) Define proper floats for parent and sub divs instead of using margin. Proper div structure won't give above gap..
below is the style for each divs.
.site-content{background:pink; width:100%; float:left}
#site-content{
background:red;
margin-left:250px;
}
#site-content-left{background:orange;float:left; width:5%; }
#site-content-right{margin:5px 0 5px 0;background:blue; float:right; display:block; width:95%}
#site-menu{
float:left;
width: 250px;
padding: 20px 0;
overflow:hidden;
background:grey;
}
.clear {clear:both}
clear:both makes the element drop below any floated elements that precede it in the document.
Remove margin: left from #site-content
#site-content{
background:red;
}
check this fiddle