DIV partition with CSS - css

I got a problem with my DIV partition. I want this:
But i found no solution. Can anybody help me?
With this solution, the all container are on the left and not centered.
#logo-text{
margin: 0 auto;
width: 600px;
float: left;
}
#image{
float: right;
}

Although you have not given any examples of what you have tried, i'd like to give you this example:
http://jsfiddle.net/LRffh/
<div id="container">
<div id="lineLeft">
<div id="boxOne">box one</div>
<div id="boxTwo">box two</div>
</div>
<div id="lineRight">
<div id="image">image</div>
</div>
<div class="clear"></div>
</div>
CSS
#container {
width: 1000px;
min-height: 1px;
background: red;
padding: 20px;
}
#lineLeft, #lineRight {
float: left;
width: 450px;
padding: 20px;
background: grey;
}
#lineLeft {
margin-right: 20px;
}
#boxOne, #boxTwo, #image {
background: white;
width: 100%;
min-height: 1px;
}
#lineLeft div, #lineRight div {
margin-bottom: 10px;
}
.clear {
clear: both;
}

HTML:
<div class='continer'>
<div class='logo'></div>
<div class='image'></div>
<div class='text'></div>
</div>
CSS:
.continer {
width:500px;
padding:10px;
background:red;
height:400px;
}
.logo {
width:200px;
padding:10px;
background:#ddd;
height:150px;
float:left;
margin:10px;
}
.text {
width:200px;
padding:10px;
background:#ddd;
height:150px;
float:left;
margin:10px;
}
.image {
width:200px;
padding:10px;
background:#ddd;
height:340px;
float:right;
margin:10px;
}
fiddle

<style>
#wrapper
{
margin:0px auto;
padding:0px;
width:1000px;
}
#side
{
margin:0px ;
padding:0px;
width:350px;
height:500px;
float:left;
}
#first
{
margin:0px ;
padding:0px;
width:350px;
height:300px;
background-color:red;
}
#Second
{
margin:0px ;
padding:0px;
width:350px;
height:300px;
background-color:blue;
}
#content
{
margin:0px ;
padding:0px;
width:650px;
height:600px;
float:right;
background-color:green;
}
</style>
<div id="wrapper">
<div id="side">
<div id="first"></div>
<div id="Second"></div>
</div>
<div id="content">
</div>
</div>
hope this helps
http://jsfiddle.net/LSsMc/48/

Here's another take on the problem
HTML
<div class='table'>
<div class='cell'>
<div class='table'>
<div class='row'>
<div class='cell'></div>
</div>
<div class='row'>
<div class='cell'></div>
</div>
</div>
</div>
<div class='cell'></div>
</div>
CSS
html, body{
width:100%;
height:100%;
padding:0;
margin:0;
}
body{
position:fixed;
}
.table{
display:table;
width:100%;
height:100%;
}
.cell{
display:table-cell;
border:1px solid grey;
width:50%;
}
.row{
display:table-row;
border:1px solid grey;
}

You need to create a container class for example who contains all the childs elements, to center the content.
html part :
<div class="container">
<div id="left">
<div id="logo-text"></div>
<div id="text"></div>
</div>
<div id="right">
<div id="image"></div>
</div>
css part :
.container {
background-color: red;
max-width: 1000px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
/* Left part */
#left {
float: left;
padding: 20px;
}
#logo-text {
background-color: darkgrey;
width: 300px;
height: 300px;
}
#text {
background-color: darkgrey;
width: 300px;
height: 300px;
}
/* Right part */
#right {
float: right;
padding: 20px;
}
#image {
padding: 20px;
background-color: darkgrey;
width: 300px;
height: 300px;
}
jsfiddle http://jsfiddle.net/LSZfH/1/

Related

How to position divs inline and custom position divs inside them?

How to get inline divs with scrollbar and other divs inside them. When I made just inline divs with scrollbar everything works fine, but when I try to put other divs inside everything collapse.
I need to have something like this:
Simple code:
<div class="inlineContainer">
<div class="inlineDiv">
<div id="customDiv1">inside div 1</div>
</div>
<div class="inlineDiv">
<div id="customDiv2">inside div 2</div>
</div>
</div>
CSS 1(inline not working properly):
.inlineContainer{
width:100%;
height:150px;
overflow:scroll;
overflow-y: hidden;
white-space: nowrap;
}
.inlineDiv{
height: 100px;
width: 100px;
display: inline-block;
position:relative;
}
#customDiv1{
position:absolute;
left:10px;
width:50px;
height:50px;
}
#customDiv2{
position:absolute;
left:20px;
width:60px;
height:50px;
}
CSS 2(inline not working properly):
.inlineContainer{
width:100%;
height:150px;
overflow:scroll;
overflow-y: hidden;
white-space: nowrap;
}
.inlineDiv{
height: 100px;
width: 100px;
display: inline-block;
}
#customDiv1{
margin-top:50px;
width:50px;
height:50px;
}
#customDiv2{
margin-top:10px;
width:60px;
height:50px;
}
CSS 3(scrollbar not working):
.inlineContainer{
width:100%;
height:150px;
overflow:scroll;
overflow-y: hidden;
white-space: nowrap;
}
.inlineDiv{
height: 100px;
width: 100px;
float:left;
position:relative;
}
#customDiv1{
position:absolute;
left:20px;
width:50px;
height:50px;
}
#customDiv2{
position:absolute;
left:10px;
width:60px;
height:50px;
}
Apply vertical-align: top; to the inline-blocks to make them align at the top of their container:
div {
border: 1px solid #777;
}
.inlineContainer {
width: 100%;
height: 150px;
overflow: scroll;
overflow-y: hidden;
white-space: nowrap;
}
.inlineDiv {
height: 100px;
width: 100px;
display: inline-block;
vertical-align: top;
}
#customDiv1 {
margin-top: 50px;
width: 50px;
height: 50px;
}
#customDiv2 {
margin-top: 10px;
width: 60px;
height: 50px;
}
<div class="inlineContainer">
<div class="inlineDiv">
<div id="customDiv1">inside div 1</div>
</div>
<div class="inlineDiv">
<div id="customDiv2">inside div 2</div>
</div>
</div>

Adding a text at the bottom of an image with a dark border

I am trying to add a dark colored border at the end of an image and write a text on it. I have attached the screen shot of how I want it to be.
Does anybody knows how to work this out?
I'm guessing something like this?
You should read up on position CSS for elements. Position absolute and relative
Fiddle for you
<div class="container">
<img src="http://placehold.it/200x150" alt="" />
<span>Here's your text</span>
</div>
* {
box-sizing: border-box;
}
.container {
position: relative;
}
.container span {
position: absolute;
bottom: 0px;
background-color: red;
width: 200px;
display: block;
padding: 10px 15px;
text-align: center;
text-transform: uppercase;
color: #fff;
}
Check this. I updated this fiddle for you! http://jsfiddle.net/EgLKV/5712/
#container
{
height:400px;
width:400px;
position:relative;
}
#image
{
position:absolute;
left:0;
top:0;
}
#text
{
z-index:100;
position:absolute;
color:white;
font-size:24px;
font-weight:bold;
text-align:center;
top:350px;
width: 400px;
background: #0686c9;
}
http://jsbin.com/tanesehivu/5/
CODE
.box{
width:200px;
height:150px;
background:grey;
float:left;
margin:10px;
display:block;
border:1px solid #999;
}
.box img{
width:200px;
height:150px;
border:1px solid #999;
}
.box span {
width:200px;
height:30px;
background:grey;
display:block;
text-align:center;
font-size:40px;
position:absolute;
top:140px;
line-height:35px;
color:#fff;
font-size:30px;
}
<div class="box">
<img src ="http://www.debrecensun.hu/media/2014/01/13-parties-for-wednesday-15-january/party.jpg"/>
<span>TITLE</span>
</div>
<div class="box">
<img src ="http://www.tnpsc.com/downloads2011/StreetRaceCars.jpg"/>
<span>TITLE</span>
</div>

Css Tricks - How to align 4 div's

I have 4 divs in my HTML, I'd love to stay the same this appearance: (Each color a div, totaling 4 (not counting the background color))
For the current scenario:
I have the following jsFiddle: HERE
My big problem is when I add another item <li> in my <ul>, the result is that I have the following:
Css with the way they are one overlaps the other :'( (crying)
body {
background-image:url('http://subtlepatterns.com/patterns/shattered.png');
margin:0;
}
.chatBody {
position:absolute;
bottom:0;
height:200px;
width:100%;
background-color:#3c454f;
border-top: 10px solid #7ac943;
}
#navlist li {
display: inline;
list-style-type: none;
width:300px;
}
.avatarUser {
height:80px;
width:80px;
background-color:yellow;
float:left;
margin-right:20px;
margin-bottom:20px;
}
li > .frdImage {
position: relative;
/*margin-top:-25px;*/
top:50%;
float:left;
margin-left:5px;
border-radius: 6px;
border: solid 2px #aaa;
height:80px;
width:80px;
background-color:yellow;
margin-right:10px;
margin-bottom:20px;
}
li > span.frdName {
position:absolute;
float:left;
margin-top:10px;
font-weight: bold;
font-family:'Verdana', cursive;
font-size: 15px;
color: white;
margin-right:200px;
}
.active{
width:300px;
}
.frdStatusIndicator{
float:left;
margin-top:40px;
height:15px;
width:15px;
background-color: #7ac943;
border-radius: 10px;
}
.frdStatusName{
float:left;
margin-top:40px;
border-radius: 10px;
font-family:'Verdana', cursive;
font-size: 15px;
color: white;
line-height:15px;
padding-left:5px;
}
Could someone kindly help me with this? Since already very grateful for the time you guys!
How about this for html
<div class="chatBody">
<div id="navlist">
<div class="tile active">
<div class="frdImage"></div>
<div class="stuff">
<div class="frdName">Igor Gomes</div>
<div class="frdStatusIndicator online"></div>
<div class="frdStatusName">Online</div>
</div>
</div>
<div class="tile active">
<div class="frdImage"></div>
<div class="stuff">
<div class="frdName">Igor Gomes the second</div>
<div class="frdStatusIndicator idle"></div>
<div class="frdStatusName">Idle</div>
</div>
</div>
<div class="tile active">
<div class="frdImage"></div>
<div class="stuff">
<div class="frdName">Igor Gomes the third</div>
<div class="frdStatusIndicator online"></div>
<div class="frdStatusName">Online</div>
</div>
</div>
<div class="tile active">
<div class="frdImage"></div>
<div class="stuff">
<div class="frdName">Igor Gomes the fourth</div>
<div class="frdStatusIndicator offline"></div>
<div class="frdStatusName">Offline</div>
</div>
</div>
<div class="tile active">
<div class="frdImage"></div>
<div class="stuff">
<div class="frdName">Igor Gomes the fifth</div>
<div class="frdStatusIndicator idle"></div>
<div class="frdStatusName">Idle</div>
</div>
</div>
</div>
</div>
and this for css:
body {
background-color: #3c454f;
}
#navlist > div.tile {
display: inline-block;
width:300px;
border: solid 1px red;
position: relative;
}
.avatarUser {
height:80px;
width:80px;
background-color:yellow;
float:left;
margin-right:20px;
margin-bottom:20px;
}
div.tile > .frdImage {
border-radius: 6px;
border: solid 2px #aaa;
height:80px;
width:80px;
background-color:yellow;
display: inline-block;
}
div.tile > div.stuff > div.frdName {
position:relative;
display: inline-block;
right: 0px;
margin-top:10px;
font-weight: bold;
font-family:'Verdana', cursive;
font-size: 15px;
color: white;
width: 200px;
}
.active{
width:300px;
}
div.tile > div.stuff {
position: relative;
top: -2em;
width: 208px;
/* border: solid 1px green; */
display: inline-block;
}
.frdStatusIndicator{
position: relative;
height:15px;
width:15px;
background-color: #7ac943;
border-radius: 10px;
display: inline-block;
}
.frdStatusName{
position: relative;
border-radius: 10px;
font-family:'Verdana', cursive;
font-size: 15px;
color: white;
line-height:15px;
padding-left:5px;
display: inline-block;
}
.offline {
background-color: #FF0000;
}
.online {
background-color: #00FF00;
}
.idle {
background-color: #FFFF00;
}
I suppose I have to do a jsfiddle for this ... http://jsfiddle.net/bbutler/TMgs5/1/
Try setting width to this div in the list i.e for eg:100px and try it wont overlap
<div style="display:inline; float:left;width:100px">
Thanks
AB
Just make your window bigger in JSFiddle.
Just check out the jsfiddle below. You were pretty much on the right track.
http://jsfiddle.net/TYZ64/4/
#navitem li
{
display:inline-block;
}
I just changed that part.

Justify divs within a div HTML/CSS

I've played around for a while with float, display, inline-block, inline, block, and can't seem to find the right way to "justify" the divs with in the div. Here is the HTML portion of it:
<body>
<div id="container">
<div align="center" id="header">
<h1>This is my header area</h1>
</div>
<nav>
HOME |
COC |
ID CARDS |
SCHEDULE |
FORMS |
CFS |
MEDIA |
LINKS |
CONTACT US
</nav>
<div class="boxes">
<div id="box1">
Content box 1
</div>
<div id="box2">
Content box 2
</div>
<div id="box3">
Content box 3
</div>
</div>
<div id="main">
<h1>This is the main Div</h1>
<p>This is my paragraph Area</p>
</div>
<div align="center" id="footer">
<h3>(This is my footer area)<br>
Copyright 2012-2013 blah blah blah </h3>
</div>
</div>
</body>
This is my CSS:
body {
font:"Times New Roman", Times, serif;
background-color:#333;
margin: 0;
padding: 0;
color:#06C;
}
nav {
padding:10px;
}
#container {
width: 80%;
max-width: 1260px;
min-width: 780px;
background-color:#0B0B0B;
margin: 0 auto;
text-align: left;
}
.boxes {
width:100%;
display:inline-block;
margin:10px;
padding:10px;
}
#box1 {
width: 150px;
height: 150px;
border:1px;
border-style:dashed;
float:left;
margin:10px;
padding:10px;
}
#box2 {
width: 150px;
height: 150px;
border:1px;
border-style:dashed;
float:left;
margin:10px;
padding:10px;
}
#box3 {
width: 150px;
height: 150px;
border:1px;
border-style:dashed;
float:left;
margin:10px;
padding:10px;
}
#main {
clear:both;
}
I've researched it but I can't really seem to get it right.
I want box 1 2 and 3 to even space throughout the width of the
Any suggestions?
replace your css with below--
body {
font:"Times New Roman", Times, serif;
background-color:#333;
margin: 0;
padding: 0;
color:#06C;
}
nav {
padding:10px;
}
#container {
width: 80%;
max-width: 1260px;
min-width: 780px;
background-color:#0B0B0B;
margin: 0 auto;
text-align: left;
}
.boxes {
width:100%;
display:inline-block;
margin:10px;
padding:10px;
}
#box1 {
width: 25%;
height: 150px;
border:1px;
border-style:dashed;
float:left;
margin:10px;
padding:10px;
margin-left:60px;
}
#box2 {
width: 25%;
height: 150px;
border:1px;
border-style:dashed;
float:left;
padding-left:25px;
margin:10px;
padding:10px;
}
#box3 {
width: 25%;
height: 150px;
border:1px;
border-style:dashed;
float:left;
margin:10px;
padding:10px;
}
#main {
clear:both;
}
Best of luck !
You can give each of your 3 boxes a 25% of width to fit the parent div.
#box1 {
width: 25%;
}
#box2 {
width: 25%;
}
...
http://jsfiddle.net/4chjf/1/

CSS footer doesn't stick to the bottom of the page

I'm having some difficulties in setting up a sticky footer in my css layout. I've been trying to go with the idea from http://www.cssstickyfooter.com/ but the footer doesn't stay at the bottom of the page if the content in the divs isn't high enough.
The css file:
* {
margin:0;
padding:0;
}
body {
height:100%;
margin:0px;
padding:0px;
}
#wrap {
min-height: 100%;
}
#container {
overflow:auto;
padding-bottom: 150px;
text-align:left;
width:800px;
margin:auto;
}
#header {
height:240px;
margin-top:20px;
}
#navigation {
float:left;
width:800px;
margin-top:20px;
}
#content-container {
float:left;
width: 800px;
}
#left {
clear:left;
float:left:
width:480px;
height: auto;
margin: 20px 0px 20px 0px;
padding: 20px 10px 20px 10px;
}
#right {
float:right;
width:275px;
height:auto;
margin: 20px 0px 20px 0px;
padding: 20px 10px 20px 10px;
}
#footer {
position: relative;
clear:both;
height:150px;
margin-top: -150px;
}
#columns {
width:800px;
height:150px;
margin:auto;
}
#colleft {
float:left;
width:400px;
height:150px;
}
#colright {
float:right;
position:relative;
width:260px;
height:150px;
}
The html file:
<div id="wrap">
<div id="container">
<div id="header"></div>
<div id="navigation">
<div id="lang"></div>
</div>
<div id="content-container">
<div id="left"></div>
<div id="right"></div>
</div>
</div>
<div id="footer">
<div id="columns">
<div id="colleft"></div>
<div id="colright"></div>
</div>
</div>
I believe you are missing html { height: 100%; } from your CSS.
Have you considered using position: fixed?
#footer { position: fixed; bottom: 0px; height:150px; }
The reason your example is not working is because your #footer is inside the #wrap, using that CSS the #footer must be outside of the wrap, as it is the wrap which is setting the min-height to 100%, and the #footer is being pulled upwards using the negative margin.
The html tag also needs a height of 100% to work.
So to recap, #footer can't be nested, and html needs height: 100%;
Example here --- http://jsfiddle.net/CK6nt/
Hope that helps! Laurie
In your footer class:
#footer {
position: relative;
clear:both;
height:150px;
margin-top: -150px;
}
Change position: relative; to position:fixed so the class should look like this:
#footer {
position: fixed;
clear:both;
height:150px;
margin-top: -150px;
}
Everything seems fine to me, you just have to add position :absolute so the footer placed out of normal document flow and bottom:0 will help you to bring the footer down the page.
#footer {
position:absolute;
bottom:0;
}

Resources