I have a CSS sidebar that will display links on my website. However, it does not fill the full page height as I want. How can I make this work?
JSFiddle: http://jsfiddle.net/Pw4FN/
The easiest way is simply to do:
height: 100vh;
Where 'vh' stands as vertical height of the browser window. Responsive to resizing of brower and mobile devices.
there is a much easier way that I thought of yesterday.
Go have a look at the website I'm busy with: http://www.atlm.co.za/aboutconcepts.html and look at the sidebar to the right in blue.
This is easily accomplished by having that sidebar as the main container nad the larger white content area to the left as a floating object...
Quite simple, just remember to clear the float to have the blue main container extend down to the bottom.
<div class="maincontainer">
<div class="maincontent_blue">
<!-- Title -->
<!-- Title__end -->
<div class="mainleft">
<h1 style="text-align:center">About Concepts</h1>
<p><img src="images/aboutlogo1.png" width="500" height="284" /></p>
<p><img src="images/aboutmp.png" width="500" height="284" /></p>
<p><img src="images/aboutp1.png" width="500" height="284" /></p>
<p><img src="images/aboutp2.png" width="500" height="284" /></p>
<p><img src="images/aboutlogo2.png" width="500" height="284" /></p>
<p><img src="images/aboutlogo3.png" width="500" height="284" /></p>
<p> </p>
</div>
<p> </p>
<p style="padding-top:40px">We designed a About Concepts' new logo for them in a record time and they were greatly impressed with our service.</p>
<p style="padding-top:185px">After the logo design, they needed us to design presentational tools for their sales people. We then sat down with the Marketing Manager, Sales Manager and a few of the sales people to really understand what the company was all about and how we were to approach the project and also how we could compliment their excellent sales team with tools that would almost do their jobs for them.</p>
<p style="padding-top:600px">After satisfying their needs and after some time they >came back to us and asked us to design a new logo that would shift trends as they were >moving into new offices with a modern design. We jumped to the opportunity to greatly >improve their already fantastic logo. This is what we came up with. We later heard back >from them and all the compliments they were getting on the great new logo. They >"stood from the crowd" as the owner stated.</p>
<div class="clearfloat"></div>
</div>
<!-- end .maincontent_blue -->
</div><!-- end .maincontainer -->
That is the html I used and the css is as follows:
.maincontent_blue {
margin-top: 0;
padding-bottom: 0;
width: 100%;
background: #00D7E8;
color:#fff;
}
.mainleft {
height: 100%;
float: left;
background: #fff;
padding-top: 5px;
padding-bottom: 10px;
width: 600px;
margin-right: 15px;
margin-bottom: 0;
}
This was quite simple to do and I suppose anyone will be able to follow my code..
position:absolute;
width:100px;
height:100%;
top:0;
left:0;
the element cant be floated, or it will not fill whole page, and cant have padding at top or bottom, the padding will cause scroll. If you need the padding top, set to the child element, like UL.
I added ul and moved the padding from the outer div to margin on the ul - now the scrollbar is gone (at least I think that was the problem?)
see http://jsfiddle.net/Pw4FN/1/
I learned this from Wordpress dashboard sidebar.
Simply write these :
html{
height:100%;
}
body{
position: relative;
min-height: 100%;
}
.sidebar{
background: yellow;
height:100%;
position: absolute;
}
I hope this help you ♥
A very late reply, none of the above helped me. I have a working solution, may help someone. using a flex along with view port for min-height helps to cover the sidebar to the whole page.
this code assumes having a top-bar of height 51px;
.user-content {
display: flex;
}
.user-content .side-bar-content {
flex : 1;
flex : 0 0 220px;
background: #f1f1f1;
min-height: calc(100vh - 51px);
//min-height: 100vh; // without topbar
}
.user-content .app-user {
flex : 2;
padding: 0 0 15px 15px;
}
You cannot float an absolute positioned element. Don't forget to set the height of both the body and the html nodes to 100%, and use a padding on the body element to avoid overlapping.
body, html {
height: 100%;
}
body {
padding-left: 200px;
}
Related
I've lost count of how many posts I've read on this subject. Frankly I am not a CSS expert. I cook-booked a 'sticky footer' that works perfectly in Firefox and Chrome but fails in IE9 and above. (Its position in IE varies with the height of the browser window. In other browsers its fixed to the bottom.)
The css is as follows:
#footer {
position:relative;
margin-top: -150px;
height: 150px;
clear: both;
bottom:0px;
}
The html (in the master page) is as follows:
<footer>
<div id="footer">
<div style="margin: auto;">
</div>
<br />
<div style="text-align: center; margin: auto; margin-left: auto;
margin-right: auto; width: 100%; margin-bottom: auto">
<p>© Copywrite blurb and date here</p>
</div>
</div>
</footer>
Suggestions?
I am a bit of a noob too, but I feel like it is the 'position: relative' which could be messing up your code. Is your footer wrapped into another div?
Maybe try wrapping your page in a content div with a height of 100%, then position relative to this, rather than the page.
Or perhaps set the body and html to have height: 100%. What is the current height of the element surrounding your footer?
Just throwing a few ideas out there. :)
For classic web sites you want to use position fixed. For a more modern, fluid, app like web application position absolute works well. You can see the latter on my demo web app, http://movies.spawebbook.com.
#footer {
position:absolute;
height: 150px;
clear: both;
bottom:0;
left: 0;
right: 0;
}
I'm learning HTML/CSS in my web standards design course this month and this week we are fixing our websites to be responsive.
I have converted all of my px to percentages and all font from px to em. I messed something up with the max-width: 100% on my gallery.
I'll post my link instead of all the codes.
http://jgoldd.github.io/wsd/index.html
Take the width and margin off your body tag. Make a class called a wrapper and add it inside your containers eg
.wrapper{
max-width:960px;
margin:0 auto;
width:100%;
}
<header>
<div class="wrapper">
// put your content in here
</div>
</header>
<div id="content">
<div class="wrapper">
// put your content in here
</div>
</div>
<footer>
<div class="wrapper">
// put your content in here
</div>
</footer>
If you don't want to do this you could just set your body to
body{
max-width:960px;
width:100%;
}
But I would change your structure to the way with a wrapper is good to practice clean code hygiene from the start :-)
Your css is too buggy. So, let me explain you a simple technique to activate responsive behavior to images
Try this code in HTML
<img class="resize" src="http://jgoldd.github.io/wsd/images/mountains1.jpg">
CSS
.resize {
max-width: 100%;
height: auto;
width: auto;
}
This code simple activates the responsive behavior on images.
Do let me know if you have any queries...! :)
You're going to need to play with it a bit, but here is a quick bit to get you going in the right direction. (remove the lines I commented with REMOVE)
#gallery li{
width: 49%;
display: inline-block;
.display: inline; /* for IE 8 */
zoom: 1; /* for IE 8 */
/* float: left; REMOVE */
}
#gallery img {
width: 100%;
/* max-width: 100%; REMOVE */
}
#gallery_container{
width: 100%;
/* width: 41.666667%; REMOVE */
}
Give it a try. Should give you better results and hopefully get you where you want to be.
I would just like the edges of my image to stretch the width of the screen. Not looking for it to be a full background.
My website is www.jobspark.ca
<div class="fullWidthSectionBG">
<div class="fullWidthSection">
<div class="myLeftColumn">
<p>
</p>
</div>
<div class="myRightColumn">
<h2>Used By Thousands Of Canadians</h2>
<p>Jobspark.ca is dedicated to providing resources for job seekers and employers throughout British Columbia and Alberta. Many top employers along with small local businesses from across the region post their jobs on Job Spark to find qualified professionals.</p>
<p>Job Spark simplifies your quest for the perfect career with a clean design and real-time postings. Our streamline job board was designed to take the headache out of finding a job.</p>
<p>Your job listings will be seen across multiple venues, receiving thousands of views each month! </p></div>
</div>
</div>
the CSS
.fullWidthSectionBG {
background-image: url('http://static.squarespace.com/static/513d5347e4b0abff73be5264/t/519c45c4e4b084baf13d7e27/1369195972115/rocktruck2.jpg');
background-position:center;
background-repeat: no-repeat;
height:575px;
margin-left: -1600px;
margin-right: -1600px;
}
This answer was close but then the rest of the website that isn't an image extended full screen.
#site > .wrapper {
max-width: 960px;
padding: 0 50px;
margin: 0 auto;
position: relative;
}
change 960px to 100%
& get rid of
margin-left: -1600px;
margin-right: -1600px;
I have been fighting with this issue for a few days now and would be soo happy to figure something out. Might have to zoom out to see the issue.
What about adding
width: 100%;
to your css rules and getting rid of the margins ? like this
Is that your question ?
#site > .wrapper {
max-width: 960px;
padding: 0 50px;
margin: 0 auto;
position: relative;
}
change 960px to 100%
& get rid of
margin-left: -1600px;
margin-right: -1600px;
to achieve this goal i typically define a div element that fits the exact size and position i want my background image to fill.
then use the css attribute for background-size:cover; this Cover attribute scales the image automatically to ensure the entire background area is in fact "covered" by image. see the documentation here
here is a jsfiddle of an example of this method working
it is also worth noting to achieve intermittent full width areas between centered fixed width areas i like to use this method of defining a .wrapper class very similar to yours. then ending that wrapper for the full width area and once again restarting it afterwards
my adjustments to your code as follows:
CSS
.fullWidthSectionBG {
background-image: url('http://static.squarespace.com/static/513d5347e4b0abff73be5264/t/519c45c4e4b084baf13d7e27/1369195972115/rocktruck2.jpg');
background-position: center;
background-repeat: no-repeat;
height:575px;
background-size: cover;
}
HTML
<div class="wrapper">
<!-- HEADER HERE -->
</div>
<div class="fullWidthSectionBG">
<div class="wrapper">
<!-- FULL WIDTH BANNER CONTENT HERE -->
</div>
</div>
<div class="wrapper">
<!-- BODY HERE -->
</div>
try it out let me know how it works - hope this helps!
so, I have a couple questions. The site in question is here:
www.vutallindustries.com/penultimatum
What I am trying to do, is get the center box to stretch between the two divs already on the side, but also take up the full screen (just not go above the top margin I already have set), Currently, the DIV will stretch with text and resize as appropriate, but only if i put in that much text. Dont like to rely on text to do my job!
The other thing, is since people will be accessing this site from various mediums, it is important that things don't overlap when the screen is stretched or resolutions are different. I have played around with different floats and widths, but this is the best I could come up with.
Additionally, on the Gallery link, any idea how to insert those images as they are but not transparent? Id like to keep the middle div transparent, but not the screenshots. Thanks for all your help!
Any additional tips errors you might see, or coding optimizations you could find would be much appreciated as well!
Here is the Style sheet:
body {
background-color:#000000;
background-image:url(http://www.vutallindustries.com/websitefiles/welcomepage.jpg);
background-repeat:no-repeat;
background-attachment:fixed;
color:#000000;
margin: 0px;
padding: 0px;
}
/* Corp Logo */
.logo {
position: fixed;
height: 128px;
width: 128px;
left: 0px;
top: 0px;
}
/* EVE Logo */
.logo2 {
position: absolute;
height: 128px;
width: 128px;
top: 0px;
right: 0px;
}
/* Site Navigation menu */
.menu {
position: fixed;
width: 128px;
height: 100%;
left: 0px;
top: 128px;
background-color:#FFFFFF;
border: 1px solid black;
text-align:left;
opacity:0.6;
filter:alpha(opacity=60);
}
/* Official EVE news via RSS */
.news {
float:right;
width: 128px;
height: auto;
margin-top: 129px;
margin-right:0px;
background-color:#FFFFFF;
border: 1px solid black;
text-align:left;
opacity:0.6;
filter:alpha(opacity=60);
}
/* website content */
.content {
width: auto;
height: 100%;
text-align: center;
background-color:#FFFFFF;
border: 1px solid black;
opacity:0.6;
filter:alpha(opacity=60);
}
/* centers website content */
div.centerbox-outer {
margin-top:129px;
margin-right:136px;
float: left;
position:fixed;
left:136px;
}
And here is the main index HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Penultimatum</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link REL="StyleSheet" TYPE="text/css" HREF="layout.css">
</head>
<body>
<div class="logo">
<img src="http://www.vutallindustries.com/websitefiles/emblem.png" alt="Penultimatum">
</div>
<div class="menu">
<p> <b> Home </b>
</p>
<p> <b> Forum </b>
</p>
<p> <b> Gallery </b>
</p>
<p> <b>Note: if anyone can figure out how to make the center box centered and scroll with, it would be much appreciated. </b>
</p>
</div>
<div class="logo2">
<img src="http://www.vutallindustries.com/websitefiles/evelogo.jpg" alt="Penultimatum">
</div>
<div class="news">
<p>
<script type="text/javascript" src="http://output42.rssinclude.com/output?type=js&id=629071&hash=623340dcbe5d6196e04dc473e9f193b0"></script>
</p>
</div>
<div class="centerbox-outer">
<div class="centerbox-inner">
<div class="content">
<p> <b>Welcome to the EVE Online corporation, Penultimatum! We are currently standing up offices, and this website is under construction. Check back in later for more details</b>
</p>
</div>
</div>
</div>
</body>
</html>
Then the gallery page is the same as the index, it just replaces the line about welcome to the EVE online corp with the following code:
<p>
<center>
<a href="http://www.vutallindustries.com/websitefiles/test.png">
<img src="http://www.vutallindustries.com/websitefiles/test.png" alt="Vutall's Character"
width="auto" height="150">
</a>
</center>
</p>
<p>
<center>
Vutall's Character
</center>
</p>
I finally came up with the solution here: http://jsfiddle.net/yKVq4/5/
Summary of Changes
I cleaned up a lot of your code, because there were a lot of redundant things.
I added containers to the left and right side because this will prevent things like writing position:fixed and width:128px a bunch of times.
I found when I changed the positioning of div.centerbox-outer to relative, but kept position:fixed later on down the line, the code suddenly centered and now always spans the full length, no matter what. After some playing around with the code, it is the combination of the right and left position that is doing it.
Because I changed the alignment of the containers from position:fixed; to float, the result was a more responsive solution. It is quite crude, but it will get the job done.
I hope this is what you are looking for.
Edit
I have found that if I change the div.centerbox-outer's positioning to absolute, then add a margin-right to the .menu-container, then there is a greater responsive design outlook
Update
I came up with a possible responsive design layout http://jsfiddle.net/yKVq4/42/
Summary
Once the screen gets to less than 400 px, move the welcome banner to the top to keep it out of the way.
Increase the menu size to 100% after it has shrunk past 300px and remove the float. Same with the other floated container. Also made the images responsive
Other Changes
Added some simple styles to the menu, after changing it into a unordered list
Added transitions
Fixed the problem with the background not working, although now it is not fixed.
I changed this a lot. But it is because I like coding so much ;)
I haven't developed much in HTML/CSS in some time and was looking at some old code and came across the following:
CSS:
#menu{
float: right;
height: 80%;
vertical-align: bottom;
}
.filler{
float: right;
height: 50%;
}
p.clear{clear: both; height: 0; margin: 0; padding: 0;}
HTML:
<div class="filler">
<p class="clear"></p>
</div>
<div id="menu">
<p class="clear"></p>
</div>
These div classes are nested inside a banner div and lie in the top right corner of the screen. Without the <div class="filler"> the menu div no longer lies within the banner div, nor at the top right of the screen. What is going on? I want to design a webpage with as little nested divs as possible. Is there a way to accomplish this same functionality without having a div that contains nothing but height?
I think the old trick here is on the p.clear having 0 height. I kinda see whats going on tho you're excluding alot of variables. Anyway. If you want a prematop right menu you could try something like :
#menu{
position: fixed;
top: 1em;
right: 1em;
}