I want to make .side-menu element's position fixed, but I have no success with the code below. .side-menu element moves with .child-container content.
Why it doesn't work and how to make it work? :)
HTML:
<div class="pageWrapper">
<div class="container">
<div class="side-menu">
Menu content
</div>
<div class="child-container">
Large Content
</div>
</div>
</div>
CSS:
body, html {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.pageWrapper {
overflow-x: hidden;
min-width: 1200px;
height: 100%;
}
.container {
position: relative;
width: 1170px;
margin: 0 auto;
height: 100%;
}
.side-menu {
position: fixed;
width: 80px;
height: 300px;
}
.child-container {
position: relative;
margin: 40px auto 0 auto;
width: 900px;
}
I have updated the code with the html of the question:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style type="text/css">
*
{
margin: 0;
}
.container
{
position: static;
padding: 0px;
width: 1200px;
margin: 0 auto 0 auto;
}
.side-menu
{
position: fixed;
background: red;
width: 200px;
}
.child-container
{
background: orange;
float: left;
width: 1000px;
margin-left: 200px;
}
</style>
<body>
<div class="pageWrapper">
<div class="container">
<div class="side-menu">
Menu content
</div>
<div class="child-container">
Large Content
</div>
</div>
</div>
</body>
</html>
Related
I'm trying to create a responsive web page. I have a header div that's 60px, and a landing div right below it that I want to take up the rest of the screen (height 100%). However, it overflows. I can't use overflow:hidden because when I zoom in, I can't scroll down anymore.
**************CSS***************
#home{
margin: 0;
height: 100%;
min-height: 100%;
width: 100%;
}
.header {
width: 100%;
height: 60px;
background-color: none;
}
.landing{
margin: 0 auto;
height: auto;
min-height: 100%;
width: 100%;
background-color: yellow;
}
*************HTML*************
<div id="home">
<div class="header"></div>
<div class="landing"></div>
</div>
How do I fix this so that my landing page doesn't overflow?
Use calc:
.landing {
min-height: calc(100%-60px;);
[...etc...]
}
html,
body {
height: 100%;
margin: 0;
}
#home {
margin: 0;
height: 100%;
height: 100%;
min-width: 100%;
}
.header {
width: 100%;
height: 60px;
background-color: blue;
}
.landing {
margin: 0 auto;
height: auto;
min-height: calc(100% - 60px);
min-width: 100%;
background-color: yellow;
}
<div id="home">
<div class="header"></div>
<div class="landing"></div>
</div>
here is a full working example for a page with a 60px tall header, with the rest of the page being filled by a div. It uses flexbox (display: flex), I changed a few things from an answer here. You may have a to change a few things (classes, ids, etc.) to get it to work for you but this should work:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
html,body {
height: 100%;
margin: 0
}
.box {
display: flex;
flex-flow: column;
height: 100%;
}
.box .row {
border: 1px dotted grey;
}
.box .row.header {
flex: 0 1 60px;
}
.box .row.content {
flex: 1 1 auto;
background-color: yellow;
}
</style>
</head>
<body>
<div class="box">
<div class="row header">
<p><b>header (60 px tall)</b>
</div>
<div class="row content">
<p>
<b>content</b>
(fills remaining space)
</p>
</div>
</div>
</body>
</html>
Background-color is not fully filling the div ( I want to color the div between the navbar and the footer), the background color is only reaching maybe half of the page, is not filling all the way down till the end of the container.
So I hope you guys can help out on getting to the source of the issue, cause I have no idea what could be causing the problem :/
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="styles.css">
<title>FunPic - Share your pictures</title>
</head>
<body>
<div class="container">
<div id="header">
<div id="navtext">
<p>FunPic - Share your pictures</p>
</div>
<div id="menu">
<ul id="navbar">
<li>Inicio</li>
<li>Subir Foto</li>
<li>Contacto</li>
</ul>
</div>
</div>
<div id="wrapper">
<div id="content">
<div id="image"><img src="images/pic.jpg"></div>
</div>
<div id="content">
<div id="image"><img src="images/pic.jpg"></div>
</div>
<div id="content">
<div id="image"><img src="images/pic.jpg"></div>
</div>
<div id="content">
<div id="image"><img src="images/pic.jpg"></div>
</div>
</div>
</div>
<div id="footer">©Fun Pic 2015 - Costa Rica</div>
</body>
</html>
Here's the CSS:
{
max-width: 1024px;
color: red;
margin: auto;
}
html, body {
width: 100%;
margin: 0 auto;
height: 100%;
}
.container {
margin: 0 auto;
width: 100%;
background-color: #E8E8E8;
height: 100%;
}
#header {
margin-bottom: 30;
width: 100%;
height: 50px;
float: left;
background: #8AE6B8;
}
#navtext {
padding: 14;
width: 40%;
float: left;
}
#navtext p {
margin-left: 40%;
}
#menu {
padding: 14;
width: 40%;
float: left;
}
#navbar {
margin-left: 65px;
width: 100%;
float: left;
}
#navbar li {
list-style: none;
margin-right: 10;
display: inline-block;
}
#wrapper {
margin: 30;
width: 100%;
float: left;
}
#content {
margin: 0 auto;
width: 40%;
height: 600px;
display: block;
}
#image {
width: 100%;
margin: 0 auto;
}
#image img {
width: 100%;
}
#footer {
margin: auto;
width: 100%;
height: 50px;
text-align: center;
background-color: #202020;
clear: both;
}
Do it like this
#wrapper {
background-color: #E8E8E8;
}
change #E8E8E8 to any color you want. This will only set the background-color property of your div between navbar and footer divs.
I got it, i noticed i was coloring the CONTAINER instead of the WRAPPER..! ugh... i feel so dumb...
I have a website with the following structure:
<html>
<body>
<div id="page">
<div id="anyContent"></div>
<div id="pagecontent">
<div id="bigContent"></div>
<div id="footer"></div>
</div>
</div>
</body>
</html>
bigContent is dynamic and often stretches to large sizes (demonstrated by its width and height). Because a lot of elements are dynamically rendered into the div, bigContent isn't set to a static width.
How can I force the footer to have the same width as bigContent?
See my example jsFiddle.
html {
margin: 0;
padding: 0;
height: 100%;
min-width: 100%;
}
#page {
min-height: 100%;
min-width: 100%;
position: relative;
}
#bigContent {
background: black;
height: 3000px;
width: 5000px;
}
#footer {
background: blue;
clear: left;
bottom: 0px;
width: 100%;
height: 100px;
}
You can set some properties to #pagecontent then it will work as per your need:
html {
margin: 0;
padding: 0;
height: 100%;
min-width: 100%;
}
#pagecontent {
float: left;
position: relative;
}
#pagecontainer {
min-height: 100%;
min-width: 100%;
position: relative;
}
#bigContent {
background: black;
}
#footer {
background: blue;
height: 25px;
width: 100%;
}
<div id="pagecontainer">
<div id="anyContent"> </div>
<div id="pagecontent">
<div id="bigContent" style="width:500px; height:150px;"></div>
<div id="footer"></div>
</div>
</div>
You have set the width: 5000px and height to 3000px.
<div id="bigContent" style="width:5000px; height:3000px;"></div>
Try this
<div id="bigContent"></div>
and add
#bigContent {
background: yellow;
height: 1000px;
width: 100%;
}
FIDDLE
You set width to #bigContent, better would be to set this width to #pagecontent.
<div id="pagecontainer">
<div id="anyContent"></div>
<div id="pagecontent" style="width:5000px;">
<div id="bigContent" style="height:3000px;"></div>
<div id="footer"></div>
</div>
</div>
http://jsfiddle.net/47hb3fcn/3/
I am encountering some problems with div.images when trying to set {height: 100%; }: computed height does not equal the parent div#placeholder's height, but the grandparent div#home-screen's.
<!DOCTYPE html>
<html>
<body>
<div id="page-wrapper">
<div id="home-screen">
<header>
<div></div>
</header>
<div id="placeholder">
<div class="images"></div>
<div class="images"></div>
<div class="images"></div>
<div class="images"></div>
</div>
<div id="cross-screen-content">
<div></div>
</div>
</div>
<main role="main">
<p>This is a test page. </p>
</main>
<footer>
<div></div>
</footer>
</div>
</body>
</html>
Page style is as follows:
* {
margin: 0;
border: 0;
padding: 0; }
html, body {
height: 100%; }
div#page-wrapper {
height: 100%; }
div#home-screen {
display: table;
margin-bottom: 25px;
width: 100%;
height: 100%; }
header,
div#placeholder,
div#cross-screen-content {
display: table-row; }
header {
height: 85px;
background-color: #f00; }
div#placeholder {
height: 100%;
background-color: #0f0; }
div#placeholder div.images {
position: absolute;
left: 5%;
margin: 5px 0;
width: 90%;
height: 100%;
min-height: 200px;
background-color: #ccc; }
div#cross-screen-content {
height: 50px;
background-color: #00f; }
footer {
height: 80px; }
Also, {min-height: 200px; } doesn't seem to work.
Any ideas?
Thank you in advance.
UPDATE 1: min-height does work, but it does not prevent the parent DIV from collapsing.
I edited the following id's - is this the effect you were after?
div#placeholder {
height: 100%;
background-color: #0f0;
}
div#placeholder div.images {
left: 5%;
margin: 5px 0;
width: 90%;
height: 100%;
min-height: 200px;
background-color: #ccc;
}
The code should be rewritten as:
<div id="placeholder">
<div id="wrapper">
<div class="images"></div>
<div class="images"></div>
<div class="images"></div>
</div>
</div>
The div#wrapper needs the following styles:
div#wrapper {
display: table-cell;
position: relative; }
On a webpage I have a container div and inside it two divs next to each other. In the first inner div I am trying to set up a CSS table that has 4 columns that evenly fill the div.
The problem I am having is that the cells seem to get their width relative to the page's width, not the table/it's parent div. If I decrease the width from 25% to something lower, it will fit, but if I scale the page, they will still wrap, as the div on the right hits the rightmost table cell.
How should I setup the layout to keep them inside the div?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
html,body, div {
display: block;
height: 100%;
width: 100%;
}
#container {
position: absolute;
height: 300px;
width: 100%;
}
.sideBySide {
position: absolute;
float: left;
height: 100%;
}
#galleria {
background-color:#0C0;
left: 0px;
right: 300px;
width: auto;
}
#tagit {
background-color: #099;
right: 0px;
width: 300px;
}
#table {
position: absolute;
margin: 0px;
padding: 0px;
display: table;
height: 100%;
width: 100%;
}
.table-row {
position: relative;
margin: 0px;
padding: 0px;
display: table-row;
width: 100%;
height: 25%;
}
.table-cell {
position: relative;
margin: 0px;
padding: 0px;
display: table-cell;
float: left;
height: 100%;
width: 25%;
padding: 20px;
}
.kuva {
position: relative;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
background-color: #999;
}
</style>
</head>
<body>
<div id="container">
<div id="galleria" class="sideBySide">
<div id="table">
<div class="table-row">
<div class="table-cell">
<div class="kuva">Cell1</div>
</div>
<div class="table-cell">
<div class="kuva">Cell2</div>
</div>
<div class="table-cell">
<div class="kuva">Cell3</div>
</div>
<div class="table-cell">
<div class="kuva">Cell4</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Remove
float: left;
from
.table-cell