How do I let a div fill in the blank space - html

I have this page with several images. On the left is a bigger image that covers 32% of the width of the page and on the right there is a 6 image grid that covers the other 68% of thw width.
I have the images resize as the page width increases or decreases and that works beautifully.
At the bottom I have a navigation menu. The problem I have is with the navigation menu.
When resizing the page the images correctly respond but that leaves a white space between the menu and the images. I want to fill that gap. I tried to lett the menu fill in that blank space but couldn't get that figured out. then I suddenly realised that that would look terrible on phone's and such as the images would become terribly small and the menu would end up on over half of the page.
So my question is: what is a good way to fix my problem? Do I need to take a whole different approach?
EDIT: I'm familiar with the concept of responsive and know there are frameworks, but the frameworks i know of only offer a Grid layout and this site has to cover the entire screen on every resolution (per client request) So if you know how to do that with something like Bootstrap let me know.
If this is not possible at all, also please let me know so I can tell the client.
Heres a quick Fiddle (Image resolutions are accurate resolutions)
HTML
<div class="content">
<div class="left">
<div id="big-block">
<img id="red-tiger" src="img/tijger2.png" alt="Tijger"/>
</div>
</div>
<div class="right">
<img class="block" id="red-cat" src="img/plaatje1.png" alt="Rode Kat"/>
<img class="block" id="wild-dog" src="img/plaatje2.png" alt="Wilde Hond"/>
<img class="block" id="red-panda" src="img/plaatje3.png" alt="Rode Panda"/>
<img class="block" id="white-tiger" src="img/plaatje4.png" alt="Siverische Tijger"/>
<img class="block" id="puppys" src="img/plaatje5.png" alt="Puppy's"/>
<img class="block" id="grey-cat" src="img/plaatje6.png" alt="Grijze Kat"/>
</div>
</div>
<div class="footer">
<ul class="menu">
<li>HOME</li>
<li>EIGEN ONTWERP</li>
<li>GALLERIJ</li>
<li>WEBSHOP</li>
<li>CONTACT</li>
</ul>
</div>
CSS
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
width: 100%;
height: 100%;
}
img {
width: 100%;
}
.content {
width: 100%;
padding-bottom: 45%;
}
/* block width */
.left, .right {
float: left;
}
.left {
width: 32%;
}
.right {
width: 68%;
}
/* smaller blocks */
.block {
width: 33.33%;
float: left;
}
/* footer */
.footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
padding-bottom: 4.6%;
background-color: black;
}
/* menu */
.footer > ul {
list-style-type: none;
margin: 0;
}
.footer > ul > li {
width: 20%;
float: left;
line-height: 30px;
text-align: center;
}
.footer > ul > li > a {
font-family:'Fjalla One', sans-serif;
color: white;
text-decoration: none;
}
.footer > ul > li > a:hover {
color: orange;
}

As we've discussed, using a responsive framework is the way to go. I would suggest bootstrap.
problem is all the frameworks I know of offer Grid layout only and
this site should be screen wide on any screen.
Again, as I said in my comment, thats not actually right. Bootstrap has a class container-fluid that will make the container span the full width. see - http://getbootstrap.com/css/#grid-example-fluid.
With regards to the sticky footer, this is possible too, see - http://getbootstrap.com/examples/sticky-footer/

You have to use responsive layouts for it.. You have to use frameworks to achieve it easily... I suggest Bootstrap...

I have tried changing your fiddle. The images fill the gap but they do not look good. Here is the link http://jsfiddle.net/0an15t5y/2/
Changed a few css.
.content {
width: 100%;
height: 80%;
}
/* block width */
.left, .right {
float: left;
}
.left {
width: 32%;
}
.right {
width: 68%;
height: 100%;
}
/* smaller blocks */
.block {
width: 33.33%;
float: left;
height: 50%;
}
/* footer */
.footer {
position: absolute;
left: 0;
height: 20%;
width: 100%;
background-color: black;
}

Related

Responsive 2-column layout trouble

I'm having trouble solving this puzzle: I'm using a 2-column layout with a fixed-width right column and a left column which takes out the remaining space. Both heights are variable. So something like this:
<div class="sidebar">sidebar</div>
<div class="main-area">main content</div>
<style>
.sidebar { float: right; width: 250px; }
.main-area { position: relative; overflow: hidden; }
</style>
Ok, so up to here everything is fine. But here comes the tricky bit. I'm using CSS3 to enable a css change when reaching a max-width of 750px. I want the sidebar to break down below and have a 100% width (so it becomes a footer for the main content). But, because in the HTML code the sidebar div is required to be first it always appears above the main area.
Any ideas on how to lay this out?
Thank you very much!
The simple answer to your question is no. You can't make your sidebar move beneath the content in your breakpoint if the sidebar falls before the content area in your HTML. At least... Not without javascript and a bunch of craziness.
That said... Just move your sidebar below your main-content div. Semantically there is no reason for you not to.
<section class="container">
<div class="main-area">main content</div>
<div class="sidebar">sidebar</div>
</section>
Some CSS changes are required to achieve this however. It's not quite as simply done as you had it previously, but not especially difficult either.
.container {
position: relative;
}
.sidebar {
position: absolute;
top: 0;
right: 0;
width: 250px;
}
.main-area {
background: red;
margin-right: 250px;
}
Here is a JSFiddle demonstrating it working.
Feel free to add varying amounts of content to either the main-content area or the sidebar and you'll see that both still have varying heights that don't interfere with each other.
HTML:
<section class="container">
<div class="main-area">main content</div>
<div class="sidebar">sidebar</div>
</section>
CSS:
.container {
position: relative;
max-width: 1024px; /* could be width: x% as well*/
}
.sidebar {
position: absolute;
right: 0; top: 0;
width: 250px;
}
.main-area {
margin-right: 260px; /* sidebar width plus 10px gap */
}
#media only screen and (max-width: 750px) {
.sidebar {
position: static;
width: 100%;
}
.main-area {
width: 100%;
margin-right: 0;
}
}
I think you can realize this with jQuery.
HTML
<div class="main-area"></div>
<div class="sidebar"></div>
CSS
.sidebar{
background-color: #000;
height: 200px;
width: 50%;
}
.main-area{
position: relative;
background-color: #ff0000;
height: 200px;
width: 50%;
}
jQuery
$(function(){
$('.sidebar').css('float', 'right');
$('.main-area').css('float', 'left');
$(window).resize(function(){
if($(this).width() <= 750){
$('.main-area').removeAttr('style');
$('.sidebar').removeAttr('style');
}else{
$('.sidebar').css('float', 'right');
$('.main-area').css('float', 'left');
}
});
});
You can see result here -> jsFiddle
Well, this is my way.
I think I found the answer here: http://jsfiddle.net/salman/TPNpy/
<div id="main-area-wrap">
<div id="main-area">Column 1</div>
</div>
<div id="sidebar">Column 2</div>
<div id="clear"></div>
#main-area-wrap{
float: left;
width: 100%;
}
#main-area {
background-color: cyan;
margin-right: 200px;
}
#sidebar{
background-color: lime;
float: left;
width: 200px;
margin-left: -200px;
}

2-Column Container 100% Body Height

I'm using this example fyi: http://www.dynamicdrive.com/style/layouts/item/css-liquid-layout-21-fixed-fluid/ (where the left column is a fixed width via px and the right is re-sizable)
I'm trying to make the height of the container 100% of the body height.
e.g. forget the bottom content (the copy code) on that page, just the top layout example, how would I make the height of that (no matter if there's content or not) 100% the body height. With content I'm trying to get it to scroll, without (if any) it needs to be 100% height of the body minimum.
Any suggestions, no luck so far..
My jsfiddle example:
http://jsfiddle.net/GtK98/1/
Have you tried
min-height:100%;
in the css?
this is a layout without a footer, If you want to add a footer comment here and I'll do that to.
Pure CSS, without Fixing the header height, with/without fixing the left side width, cross browser (IE8+)
Take a look at that Working Fiddle
HTML: (very basic)
<div class="Container">
<div class="Header">
</div>
<div class="HeightTaker">
<div class="Wrapper">
<div class="LeftContent">
</div>
<div class="RightContent">
</div>
</div>
</div>
</div>
CSS:
*
{
margin: 0;
padding: 0;
}
html, body, .Container
{
height: 100%;
}
.Container:before
{
content: '';
height: 100%;
float: left;
}
.HeightTaker
{
position: relative;
z-index: 1;
}
.HeightTaker:after
{
content: '';
clear: both;
display: block;
}
.Wrapper
{
position: absolute;
width: 100%;
height: 100%;
}
.Header
{
/*for demonstration only*/
background-color: #bf5b5b;
}
.Wrapper > div
{
height: 100%;
overflow: auto;
}
.LeftContent
{
float: left;
/*for demonstration only*/
background-color: #90adc1;
}
.RightContent
{
/*for demonstration only*/
background-color: #77578a;
}

Half fixed, half scrollable layout that can be scrolled... CSS

I have an exotic design that needs the following. The left side must scroll, while the right side + top head must stay put (fixed). See attached image.
I can accomplish this by position: fixed on the top and right side. The top & right hand side stays put while the left scrolls.... BUT then the PROBLEM is that there is NO scroll bar anymore if anybody zooms in and you also cannot scroll left to right to see whole page
How would one attack such a layout?
Thank You.
Could not post code before - let me try again:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exotic</title>
<style type="text/css">
#top {
background-color: #FF0;
width: 1800px;
height: 50px;
position: fixed;
left: 0px;
top: 0px;
}
#sideLeft {
float: left;
width: 950px;
background-color: #9C0;
clear: left;
}
#sidebarLeft {
background-color: #0CC;
height: 800px;
width: 300px;
float: left;
}
.list {
float: left;
width: 600px;
margin-top: 100px;
}
#ordoner {
background-color: #F90;
float: left;
width: 640px;
height: 800px;
position: fixed;
top: 50px;
left: 950px;
}
#sidebarRight {
width: 210px;
height: 800px;
position: fixed;
top: 50px;
left: 1590px;
background-color: #0CF;
}
</style>
</head>
<body>
<div id="top">
</div>
<div id="sideLeft">
<div id="sidebarLeft"><!--end #sidebarLeft--></div>
<div class="list"><!--end .lisist--></div>
<!--end #sideLeft--></div>
<div id="ordoner"><!--end #ordoner--></div>
<div id="sidebarRight"><!--end #sidebarRight--></div>
<div id="footer"></div>
</body>
</html>
Clarification:
My css reflects 2 things in the right hand side but the point is that the right and the top should be static while the left scrolls... AND they should be horizontally scrollable IF a user zooms :)
Also, I've tried wrapping things in a container div, but that has its own problems - it scrolls but never reaches the right hand side if the window is not maximized.
Thanks again.
To clarify: As an example to get my point across... please resize the stackoverflow window to half your horizontal screen size... Now see how you can scroll left to right? If you zoom in, you can scroll left to right also to see the whole page. Well, in my layout, which works in full screen browser mode... once I resize that scroll bar at the bottom does not appear at all leaving the user with no ability to scroll horizontally. See picture below
Fiddle
http://jsfiddle.net/moby7000/tWb3e/
Its not very hard to create a layout like this.
I created one for you, see that Working Fiddle
HTML:
<div class="Container">
<div class="Header">
<p>The Header div height is not fixed (But he can be if you want it to)</p>
<p>This Layout has been tested on: IE10, IE9, IE8, FireFox, Chrome, Safari, Opera. using Pure CSS 2.1 only</p>
</div>
<div class="Content">
<div class="Wrapper">
<div class="RightContent">
<p>You can fix the width of this content.</p>
<p>if you wont, his width will stretch just as it needs to.</p>
</div>
<div class="LeftContent">
<p>this will scroll</p>
</div>
</div>
</div>
</div>
CSS:
*
{
margin: 0;
padding: 0;
}
html, body, .Container
{
height: 100%;
}
.Container:before
{
content: '';
height: 100%;
float: left;
}
.Header
{
margin-bottom: 10px;
background-color: #6ea364;
}
.Content
{
position: relative;
z-index: 1;
}
.Content:after
{
content: '';
clear: both;
display: block;
}
.Wrapper
{
position: absolute;
width: 100%;
height: 100%;
}
.Wrapper > div
{
height: 100%;
}
.LeftContent
{
background-color: purple;
overflow: auto;
}
.RightContent
{
background-color: orange;
float: right;
margin-left: 10px;
}
Bonus:
with a little change in the CSS, you can create a beautiful scrolling.
See that Fiddle
Edit:
If you want to set a width value to the left side, that is actually bigger then the body size (and to have an horizontal scroll), do it that way.
<div class="LeftContent">
<div style="width:1200px;"> <-- better to aplly the width from the CSS
..<The content>..
</div>
</div>
you need to add overflow:auto; to the area you want to scroll.
Have you tried
overflow-y: scroll;
in body?

Responsive CSS circles that can hold centered content

I am searching for a way to create a responsive CSS3 circle that can hold centered content.
Regarding the circle, I found some good info in this question. Too bad it seems that one can't center the content in this one.
This question is also pretty similar to mine, despite the fact it's an image that should be centered. Using a background image in not an option in my case, so this option isn't working for me as well.
Do you have any ideas how I could approach this?
Of course I could use an image, but CSS would be much more elegant!
Pure CSS requiring many extra wrappers
UPDATED: Original posting (which I deleted) missed the fact that you were seeking a responsive design. Building upon my answer for the responsive circles question you reference seems to work in all CSS3 browsers, see fiddle.
HTML (requiring five levels of wrapper, I only show one circle in this html)
<div class="circles">
<div>
<div>
<div>
<div>
<!-- BEG Content -->
All types of content (see fiddle)
<!-- END Content -->
</div>
</div>
</div>
</div>
<!-- ditto the above 3 more times -->
</div>
CSS
.circles{
margin:0px auto;
}
.circles > div {
overflow:hidden;
float:left;
width:auto;
height:auto;
position: relative;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
-khtml-border-radius: 50%;
background:#eee;
}
.circles > div > div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.circles > div > div > div {
display: table;
width: 100%;
height: 100%;
}
.circles > div > div > div > div {
display: table-cell;
text-align: center;
vertical-align: middle;
}
#media (max-width: 320px)
{
.circles > div {padding: 50%;}
}
#media (min-width: 321px) and (max-width: 800px)
{
.circles > div {padding: 25%;}
}
#media (min-width: 801px)
{
.circles{width:800px}
.circles > div {padding: 12.5%;}
}
If the height of the content is fixed and you want a CSS method, use the following properties to apply to what's inside the cicle
margin: auto; /*will center the element*/
position: relative;
top: 50%;
margin-top: - [here insert the height of the element if you know in advance / 2]px
The accepted answer did not work for me, since I wanted to rotate the circle.
This does:
HTML
<div class="mycircle">
<div class="mycontent">
<span>TEXT</span>
</div>
</div>
CSS
.mycircle {
width: 30%;
height: 0;
padding: 15% 0; //padding top & bottom must equal width
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
background: #dedede;
}
.mycontent {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
}
.mycontent:before {
content: '';
vertical-align: middle;
display: inline-block;
width: 0;
height: 100%;
}
.mycontent span {
vertical-align: middle;
display: inline-block;
}

Square DIV with Content in a Fluid Layout

SO,
I've created a four-column fluid-width layout for a site, and I'm working on placing a fluid square DIV within one of my columns. There are a few techniques I've found to achieve this - namely, setting padding-bottom to the same percentage as the width - but none of these seem to work when the DIV contains content.
Is there a way to maintain a 1:1 (square) ratio on a fluid DIV when that DIV contains content?
Here's my HTML:
<div id="leftmostcolumn">
<div id="logo"></div>
</div>
<div id="leftcolumn"></div>
<div id="rightcolumn"></div>
<div id="rightmostcolumn"></div>
And my CSS:
body {
width: 100%;
height: 100%;
background-color: red;
}
#leftmostcolumn {
position: absolute;
top: 0;
left: 0;
width: 25%;
height: 100%;
background-color: blue;
}
#leftcolumn {
position: absolute;
top: 0;
left: 25%;
width: 25%;
height: 100%;
background-color: green;
}
#rightcolumn {
position: absolute;
top: 0;
left: 50%;
width: 25%;
height: 100%;
background-color: yellow;
}
#rightmostcolumn {
position: absolute;
top: 0;
left: 75%;
width: 25%;
height: 100%;
background-color: gray;
}
#logo {
width:100%;
padding-bottom:100%;
background-color: #aa2d2d;
color: white;
}
​​
And here's a JsFiddle.
The DIV "logo" is the one I'm trying to maintain as a square. Right now, I've used the padding-bottom approach but that doesn't do the trick when there's content in the DIV. Any input is greatly appreciated!
Marca
EDIT:
Getting there...I'm adapting a script I found to find the width of the DIV and then apply that value to the height to keep it a square. However, as it stands now the script doesn't constantly resize the DIV, and it won't allow it to shrink below a certain size. Any thoughts on how to correct either of these issues?
HTML:
<div id="box"></div>
CSS:
​ #box { width: 75%; height: 50px; background-color: black; }​
JQUERY:
$("#box").css("height", function() {
return $(this).width();
});
JsFiddle is here.
This is something I've actually been messing around with for a while, and have come up with a quasi (but not entirely) hacky, CSS-only solution that seems to work on most browsers in the past decade. The trick is to use images, and positioning in a tricky fashion. Consider the following (simplification) of your code.
Markup:
<div class="sqr_box">
your content goes here!
</div>
CSS:
.sqr_box
{
width: 50%; /* or 100px, or 20em, or whatever you want */
border: solid 2px pink;
background-color: grey;
color: white;
}
Now, we can't set the height in terms of percent, so we won't; instead, first we'll go into Photoshop, and make an image that is 2x2 px, transparent, or background-colored. Next we'll add the following to your markup:
<div class="sqr_box">
<img src="images/sizers/2x2.png" class="sizer">
<div class="content">your content goes here!</div>
</div>
and THIS to your CSS:
.sqr_box
{
width: 50%; /* or 100px, or 20em, or whatever you want */
position: relative; /* static positioning is less than ideal for this scenario */
}
.sqr_box > img.sizer
{
display: block; /* images default to an inline-block like thing */
width: 100%;
height: auto; /* CLUTCH!!! this ensures that the image's height changes to maintain proportions with it's width */
visibility: hidden;
}
.sqr_box > .content
{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%; /* Our parent element now has a dynamically assigned height, this will work */
border: solid 2px pink;
background-color: grey;
color: white;
}
Best of all, this will work for any sized ratio of box you'd want! Just change the proportions of the image!
Hope this is all still relevant to you, 3 months later.
-Sandy
Put all four columns in one div. set that div to 100% width and set the font size to 100em
Have each of your four columns have a width of 25em instead of 25%
Have your logo width and height set to 25em each