3 column responsive footer - html

I have a responsive grid layout for thumbnail images and a full width header. It is built using 'ul' and 'li' to make the grid. So basically I'm not using a responsive grid layout throughout. Although I would like to have a three column footer at the bottom that is responsive (stack on top of each other)
I want the first column to align full left and the other two columns to align right. each column is only around 15% of the total width (so i couldn't just have all three width 33%) I want the functionality of a three column layout like in many of the themes like skeleton boilerplate, etc
I am having trouble making a good css markup that will work, I have used...
css
F1 {
padding: 15px;
width: 100px;
margin: 0 0 0 20px;
float: right;
}
.F2 {
float: left;
text-align: left;
}
.F3 {
font-size: 13px;
text-align: right;
float: right;
}
but that just separates the divs, and doesn't offer much control
any help or references to help are greatly appreciated

If I'm understanding this correctly, the following can work. Shown with divs, but a ul & li structure would work as well.
HTML:
<div class="footer">
<div class="f1">first left</div>
<div class="f2">middle right</div>
<div class="f3">last right</div>
</div>
CSS:
.footer {
text-align: center;
width: 100%;
}
.f1 {
background: green;
padding: 0;
margin: 0;
}
.f2 {
background: pink;
}
.f3 {
background: blue;
}
.f1,
.f2,
.f3 {
-moz-box-sizing: border-box;
box-sizing: border-box;
display: inline-block;
text-align: right;
font-size: 12px;
padding: 0 8%;
min-width: 300px;
width: 33%;
}
.f1 {
text-align: left;
}
If you set your divs to display inline-block with a min-width, on browser resize the columns will begin to stack one on top of the other.
Alternatively, depending on styling, you might want to set them to inline-block without a min-width, and set a media query for them to display block on all screen sizes you want them stacked one on top of the other.
If you set box-sizing to border-box, you can add the necessary padding to the inside of the container to keep the content area around 15% of the total width.
Hope this helps!

Related

How to do CSS column layout with a "floating" object spanning multiple columns?

I'd like to create a layout in CSS that looks something like this:
+----------------+ __5_____
| | __6_____
| | __7_____
| | __8_____
+----------------+ __9_____
___1____ __3_____ __10____
___2____ __4_____
Basically, the text (in the above diagram, the lines labelled 1 through 10) are arranged in a three-column layout, with a block (image, or whatever) sitting in the top left, occupying two columns, displacing the text.
Importantly, I'd REALLY like to avoid manually specifying where the column breaks are, because the content is user-provided. I have been using the CSS columns family of properties (column-width, column-count, etc.) to get the column layout for the text, but I'm not having much success putting the big floating block where I want. Is there a way to do this that doesn't involve a pile of JS to compute the optimal column break locations, and generating the columns myself?
Edited to add: in case it's not clear, in this example there are 10 rows but in practice I need to be able to deal with an arbitrary number of rows and still get columns of roughly equal height.
You can try setting your image div width to 66% of the container, and add padding in both sides to align it with the white space between the columns:
.div-with-image {
width: 66%; // 2/3 of the container
padding: 0 20px; // assuming 20px gutters for the columns
}
UPDATE
As the current state of the CSS Multi-column Module, the only "natural" alternatives to make an image span through several columns is either through the column-span property or overflowing the image inside the column.
However, column-span doesn't support -yet- other values than none (default) and all, and the overflow won't displace the text in the next columns but would just cover it or will be clipped by the containing column (depending on the browser).
The cleanest solution that comes to my mind:
Absolute position your image to the top left corner and define its width to span 2 columns, set the top margin of the first paragraph to the height of your image and insert a break before a dummy element (just a placeholder, could be a span) identified with a class. Finally, as that dummy element will be in the first line of the second column, you can assign the same margin top as you did with the first paragraph of the first column.
#image-placeholder {
width: 600px;
height: 200px;
background-color: lightgreen;
position: absolute;
top: 0;
left: 0;
}
#columnized {
-moz-column-width: 300px;
column-width: 300px;
position: relative;
}
#columnized p:nth-child(2) { // the image is the first child
margin-top: 200px;
}
.break { // your dummy element (I used a span)
break-before: always;
display: inline-block;
margin-top: 214px; // I had to tweak the margin a little
}
Additional notes
I know that you made your snippet as simple and possible, but, just in case: remember to add p tags and make it responsive (best practices). You may want to set the height of the #columnized div to use the same break across different screen sizes.
You could just do a simple two column layout and split one in half where needed.
JSFiddle
/* 2 column grid */
.gridWrapper {
width: 80%;
float: none;
margin: 0 auto;
margin-top: 50px;
margin-bottom: 50px;
}
.column {
float: left;
width: 50%;
padding: 10px;
box-sizing: border-box;
}
.column img {
width: 100%;
max-width: 400px;
height: auto;
margin: 0 auto;
display: block;
padding: 10px;
box-sizing: border-box;
}
.column p {
float: left;
width: 100%;
padding: 10px;
margin: 0 0 5px;
box-sizing: border-box;
text-align: center;
border: 1px solid gray;
}
.left, .right {
border: 1px solid blue;
}
.split {
float: left;
width: 50%;
padding: 10px;
box-sizing: border-box;
text-align: center;
border: 1px solid red;
}
<div class="gridWrapper">
<div class="column left">
<div class="image">
<img src="http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_709722401??hei=64&wid=64&qlt=50">
</div>
<div class="split">
<p>1</p>
<p>2</p>
</div>
<div class="split">
<p>3</p>
<p>4</p>
</div>
</div>
<div class="column right">
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
</div>
</div><!-- END gridWrapper -->

Aligning nav with logo using relative positioning

My CSS positioning skills have always been truly terrible. I'm looking to place my nav bar next to my logo, as well as making it move with the page and not get all screwy on anything smaller than a maximized window on a 1080p screen.
What it currently looks like: http://5.9.78.201/abellant/
It will likely look odd if you're on a different screen size.
I've (so far) used methods found on here, to no avail, using relative, absolute, and even clearing before giving up on it.
Can anyone show me where I'm screwing this up? I'm quite embarrassed by the fact that of all things, my positioning is just so bad.
Thank you.
If you want to position your logo and navbar at the center of the page::
Set #header "display:inline-block", "height:auto" and "text-align: center;" and remove all the css you have added to #logo and #navigation
#header {
width: 100%;
height: auto;
background: #f2f2f2;
margin: 0;
padding: 0;
box-shadow: 0 1.5px 1px #777;
display: inline-block;
text-align: center;
}
And if you want to set your logo and navigation side by side::
#header {
width: 100%;
height: auto;
background: #f2f2f2;
margin: 0;
padding: 0;
box-shadow: 0 1.5px 1px #777;
display: inline-block;
}
#logo {
float: left;
width: 50%;
}
#navigation {
float: right;
margin: 40px;
}
If you want to move your header section with page scroll. Set #header to "position:fixed".
So part of the problem is that you have a fixed left and right margin. Remove the fixed left and right margin for #logo and #navigation and do something like the following in your CSS:
#header {
margin: 0 auto; /* 0 px on top and bottom, auto on left and right => centered for a block element */
width: 960px; /* You need a width that will accomodate the logo and nav */
}
To make this work at other sizes, you'll need to look into CSS3 breakpoints. Here is a tutorial:
https://developers.google.com/web/fundamentals/design-and-ui/responsive/fundamentals/?hl=en
I solve your problem.
.container {
min-width: 500px;
position: relative;
text-align: center;
}
#logo {
display: inline-block;
vertical-align: middle;
}
#navigation {
display: inline-block;
}
If you noticed that the logo and the menu are NOT perfectly center it's because your image has a small white space, if you could delete that space and replace the new image it will be PERFECTLY center :)

reposition html elements through css according to screen size

when the screen size changes to less than 992px , i want the center div to come first and occupy 100% of the width whereas the left and right column should come right below it and share 45% 45% width on the same line, i want to use this for tablets, but when i try to reposition them, i manage to push the center up first but the right div falls below the left div leaving a large space to the right.
instead of
....center....
.left..right.. i get
....center....
left..........
right.........
below is the complete css & html for the divs
<section class="cbs-center-container">
<div class="column-type-1"> (left column)
</div>
<div class="cbs-content-col"> (center content)
</div>
<div class="column-type-1"> (right column)
</div>
</section>
.cbs-center-container (container)
{
padding: 30px 30px 13px 30px;
background:#eeeeee;
}
#cbs-content-col, (center div)
{
float: left;
min-height: 1px;
}
#cbs-content-col {
width: 50%;
padding: 5px 10px 60px;
}
.column-type-0{
float: left;
}
.column-type-0{
width: 25%;
position: relative;
min-height: 1px;
padding-right: 5px;
padding-left: 5px;
}
#media only screen and (max-width: 992px) {
.cbs-center-container {
display:table; (first i display container as table)
}
#cbs-content-col{
display: table-header-group; (this is the div i want to show first)
width: 100%
}
.column-type-0 {
width: 45%;
display: table-footer-group; (this 2 columns should come second )
position: relative;
height: auto;
padding-right: 5px;
padding-left: 5px;
}
}
#media (max-width: 640px){ (mobile display)
.column-type-0{ width: 80%;
position: relative;
min-height: 1px;
padding-right: 5px;
padding-left: 5px;
margin: auto;
}
}
please help , how do i re position dom elements with ease,
its best a solution without flexbox, didnt the community think about this,
i just realised i need it now since i got into responsive web design and if i may ask isn't and average tablet screen size around 1000px ?
Most of the time you dont need to use custom css for the positioning, you just add the float to the styling.
div div_name {
float: left;
/* remaining code goes here...........*/
}

Aligning last div elements

I've tried to align last div element / elements using text-align-last property but it didn't work. I have much divs in the center, but my page is different on each resolution so I can't control if elements will be perfectly and none of them will be in last line alone or so, that's why I want to align them to left.
Fiddle: http://jsfiddle.net/ecn8c0pt/
Picture of my site:
Adding the following CSS will work.
http://jsfiddle.net/ecn8c0pt/1/
#gallery h2{
margin: 0;
height: 80px; /*Added height for the Heading */
font-size: 1.1em;
font-weight: 300;
color: #33CCFF;
}
.project{
display: inline-block;
margin: 0 15px 40px;
width: 156px; //To show in jsfiddle i reduced the width.
text-align: left;
float: left; //MUST CHANGE: Once you align left it will automatically float to left. Also the number of count per row will depends on the window width and div width.
}
.project .thumbnail{
width: 156px;//To show in jsfiddle i reduced the width.
height: 144px;
border-radius: 3px;
}
try adding styles to your CSS like these:
float:left;
min-width: 200px;
max-width: 200px;
and try to fix the width for the wrapping div tag
for example:
.wrapper {
width:1000px;
}
see in example DEMO and try to predict the width now when you control it good luck!

Footer out of alignment on zoom in / zoom out

I'm currently having a problem with a website's footer.
When working on it at 100% size (normal size) the footer is nicely aligned. However, when I resize it it goes totally out of alignment and sits to the left, it needs to stay centred.
Screen shot:
Relevant CSS:
/* Dark blue area above the main part of the footer, stays aligned */
#footerUpper {
clear: left;
width: 100%;
vertical-align: top;
background-color: #252B76;
text-align: center;
color: #FFFFFF;
margin-top: 30px;
/* padding: 5px;*/
}
#footerUpper ul {
padding: 0;
margin: 25px 0px;
list-style: none;
}
#footerUpper li {
display: inline;
padding: 0 52px;
font-size: 14px;
font-weight: bold;
}
#footerUpper li a {
text-decoration: none;
color: #FFFFFF;
}
/* Main part of the footer */
#footer {
float: left;
width: 100%;
color: #252B76;
background-color: #89B0F1;
padding: 5px;
}
/* Table within the footer */
#footerTable {
width: 980px;
margin-left: 150px;
}
Thanks.
Without seeing more of the code, or a working example of it it's difficult to get too much of an idea about what's going wrong.
But I think a solution might be to have a static width on the inner-content, so for example the content that is mis-aligning itself, which I think is your "footerTable" - apply "margin:0 auto" to it to centre align it, this is assuming it's parent is 100% width, which I believe it is. Also, remove any other margin rules that apply to it.
It's because you're floating the footer to the left, and then there's no container of the footer which is centrally aligned. You can either:
Remove float: left and instead do a margin-left: auto; and margin-right: auto;
Make a container for your footer (or preferably your entire layout if it's all to be centrally aligned) and align the container to the center using margin-left: auto; and margin-right: auto;
There are of course other ways to centrally align block elements, but these are the most effective and recommended.
Since you have no reason to be floating the footer (so you say):
Remove the following styles:
float: left;
width: 100%;
Then, to make sure the table is centered, add this style:
text-align:center;
And you should find the footer stretches to the page width, no matter what zoom.