I'm looking for some help with my CSS layout. I can't seem to get it how i want. Here is an image of what i am looking for.
Required Layout Image
I can't get div2 to fill its' section with the overflow being visible to the bottom of the left column.
Here is my code that i am using to show where i am at. Please some help would be great! I'm looking to target IE6+
body {
margin: 0;
padding: 0;
height: 100%;
overflow: auto;
}
.leftContent {
position: absolute;
left: 0;
top: 0;
padding: 0;
width: 250px;
height: 100%;
color: #333;
border: red ridge;
background: blue;
overflow: hidden;
}
.centreContent {
margin-left: 254px;
margin-right: 1px;
margin-bottom: 20px;
color: #333;
background: green;
border: red ridge;
padding: 0 0px;
height: 100%;
}
.rightContent {
position: absolute;
right: 20;
top: 0;
padding: 0;
width: 100px;
color: #333;
background: black;
border: red ridge;
}
.div1 {
border: black solid;
}
.div2 {
overflow: auto;
height: 100%;
border: black solid;
}
<!-- Start Left Column-->
<div id="leftColumn" class="leftContent">
<div id="div1" class="div1">
CONTENT
</div>
<div id="div2" class="div2">
CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
CONTENT CONTENT
</div>
</div>
<!-- End Left Column-->
<!-- Start Centre Column-->
<div id="centreColumn" class="centreContent">
CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
</div>
<!-- End Centre Column-->
<!-- Start Right Column-->
<div id="rightColumn" class="rightContent">
CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
</div>
<!-- End Right Column-->
Thanks for your help.
Why you're using "position: absolute ?
Remove position, left, right bla bla and
.leftContent { float:left;}
.centreContent {float:left;}
.rightContent {float:right;}
use this CSS Codes...
Related
I'd like to cover with overlay a specific div where width and height of that div is variable. How can I do that?
Here is the fiddler for reference.
.c1 {
border: 1px solid red;
padding: 10px;
margin: 5px;
}
.overlay {
position: relative;
z-index: 1000;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.85);;
opacity: 1;
}
<p>
content before
</p>
<div class="c1">
<div class="overlay"></div>
<div class="c2">
<h1>
some content
</h1>
<p>
some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
</p>
<p>
some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
</p>
</div>
</div>
<p>
content after
</p>
You can get it with positioning parent and overlay container, when width and height is variable. Set parent .c1 position as relative and the .overlay position as absolute. Check below snippet for reference.
.c1 {
border: 1px solid red;
padding: 10px;
margin: 5px;
position: relative;
}
.overlay {
background-color: rgba(255, 255, 255, 0.85);
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
<p>
content before
</p>
<div class="c1">
<div class="overlay"></div>
<div class="c2">
<h1>
some content
</h1>
<p>
some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content
under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
</p>
<p>
some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
</p>
</div>
</div>
<p>
content after
</p>
I've encountered a problem IE11 has (maybe other IE's too), where the centered elements (using absolute position method) are not positioned properly if parent has no fixed size. The size is determined by the content.
Is there any known workaround for this?
Example:
.box{
position: absolute;
top:0;
right: 0;
left: 0;
bottom:0;
margin:auto;
height:20px;
width:20px;
background-color:#000;
}
.container{
position: relative;
background:red;
padding-left:100px;
}
<table>
<tr>
<td class="container">
<div class="box">
</div>
</td>
<td>
Some content Some content Some content Some content Some content <br>
Some content Some content Some content Some content Some content <br>
Some content Some content Some content Some content Some content <br>
Some content Some content Some content Some content Some content <br>
</td>
</tr>
</table>
you should use <div> as a parent because relative position for <td> won't work on IE
check the updated snippet
.bg {
background: red;
}
.box {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
height: 20px;
width: 20px;
background-color: #000;
}
.container {
position: relative;
padding-left: 100px;
}
<table>
<tr>
<td class="bg">
<div class="container">
<div class="box">
</div>
</div>
</td>
<td>
Some content Some content Some content Some content Some content <br> Some content Some content Some content Some content Some content <br> Some content Some content Some content Some content Some content <br> Some content Some content Some content
Some content Some content <br>
</td>
</tr>
</table>
Here is my template i would like to fill the footer like on this website kars4kids.com (scroll down to the footer)
.footer {
padding: 180px 0;
background-color: #222222;
width:100%;
The <footer> tag is inside the .container. Kindly get it out of the wrapper, or change it to fluid container.
<footer>
<div class="container"> <!-- This is the reason -->
<div class="row">
<div class="col-md-3 col-sm-6">
Or change it to container-fluid.
You'll need to make the outer element (footer) to take up the full width and have another element inside to hold your content and format it correctly in the middle.
<footer>
<div class="container">
<!-- content -->
</div>
</footer>
footer {
background: #E5F4FE;
padding: 0;
margin: 0;
display: block;
}
footer .container{
width: 70%;
max-width: 1050px;
margin-right: auto;
margin-left: auto;
}
I've created an example here http://codepen.io/AVDW/pen/xVgLyO
In this site I have a wordpress theme with this HTML structure:
<header>
<nav> ... </nav>
</header>
<div class="post-content"> ... </div>
header {
float:left;
with:30%;
}
.post-content {
float:right;
with:30%;
}
And I want to add widgets to the left column.
My options are:
1)make header widgetable: widget will appears before content and this is bad for seo.
2)put the header and the sidebar in a wrapper: the same, widgets before content
My question is: is an html bad practices to put header inside other div? And put the header after content in the html? What is the best structure for doing it?
I think the pest solution for you is to place the header with position: absolute. For that you will need to have fixed height of header element.
<div class="wrapper">
<header>
</header>
<div class="sidebar">
</div>
<div class="post-content">
</div>
</div>
CSS:
header{
position: absolute;
width: 300px; /* give your desired width */
height: 200px; /*give your desired height */
top: 0;
left: 0;
}
.sidebar{
width:30%;
float: left;
padding-top: 200px /* this is the header height */
}
.post-content{
width:70%;
float: right;
}
Of course, in HTML you can put post-content before sidebar and it will also work.
I am trying to go from a 2-col layout on Desktop like so:
To a 1-col layout on Mobile like so:
I am having trouble getting container #5 to the correct position on Desktop. My markup (modified for brievity) is like so (this can be changed to whatever):
<div id="container-1></div>
<div id="container-2></div>
<div id="container-3></div>
<div id="container-4></div>
<div id="container-5></div>
On desktop: #1 and #5 are floated left, the rest are floated right. But this causes #5 to be position right next to #4 (#5 top-aligned with #4) instead of right below #1. I thought it should've worked. Am I missing something here?
PS: All the containers' height are fluid
Try wrapping the middle 3 in an extra container and wrapping that.
<div id="container">
<div id="container-1">content content content content content content </div>
<div id="containerwrapper">
<div id="container-2">content content content content content content </div>
<div id="container-3">content content content content content content content content content content content content </div>
<div id="container-4">content content content content content content content content content content content content </div>
</div>
<div id="container-5">content content content content content content </div>
</div>
and the CSS:
#container { background: none; float: left; width: 340px; }
div { margin: 10px; margin-bottom: 0; background: #0f0; }
#container-1 { float: left; width: 60px; }
#containerwrapper { background: none; float: right; margin: 0; }
#container-2 { width: 240px; }
#container-3 { width: 240px; }
#container-4 { width: 240px; }
#container-5 { float: left; width: 60px; }
You can see it here: http://jsfiddle.net/GcYuh/