I am trying to use the trick of two nested elements to make content scroll without the scrollbar being visible.
To illustrate what I mean:
<div class="outer">
<div class="inner">
//content here
</div>
</div>
The content is higher than the outer div, so I want it to scroll. However I don't want a visible scrollbar. So I set the following CSS:
.outer {
overflow: hidden;
}
.inner {
overflow-y: scroll;
width: 110%;
}
However this is behaving quite oddly. It works to an extent - the content scrolls slightly. However it doesn't scroll as far as it needs to to be visible, and the inner div seems to ignore the padding on the outer div.
This is my full CSS. The relevant bits are .section and .innerSection
/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
html, body {
background-color: #330033;
height: 100%;
width: 100%;
color: #FFFFCC;
font-family: 'Andika', sans-serif;
font-size: 20px;
font-weight: 400;
text-align: center;
}
a:link{text-decoration: none; color: #FFFFCC;}
a:visited{text-decoration: none; color: #FFFFCC;}
a:hover{text-decoration: none; color: white; font-weight: bold;}
form {
margin: 0 auto;
max-width: 500px;
padding-bottom: 1em;
text-align: left;
}
h1 {
font-size: 72px;
}
h2 {
font-weight: 600;
}
h3 {
font-size: 64px;
}
.imgLink {
border-radius: 5px;
margin: 1%;
max-width: 50%;
}
.innerSection {
height: 100%;
overflow-y: scroll;
width: 110%;
}
.section {
background-color: rgba(51,51,51,0.5);
border-radius: 5px;
display: inline-block;
margin: 1%;
max-height: 42%; /*simplifies responsive height lower down*/
min-height: 42%;
overflow: hidden;
padding: 1%;
vertical-align: top; /*otherwise sections move down when content added*/
width: 28%;
}
#desktopTitle {
background-color: #330033;
}
#tabletTitle {
display: none;
}
#media screen and (max-width: 1020px), screen and (max-height: 925px) {
.section {
display: block;
max-height: fit-content;
min-height: 25%;
width: 94%;
}
#contact {
margin-top: 5%;
}
#desktopTitle {
display: none;
}
#resources {
display: none;
}
#tabletTitle {
display: block;
}
#twitter {
display: none;
}
}
#media screen and (max-width: 600px) {
#tabletTitle {
font-size: 48px;
}
}
Try this (modifications are commented):
.innerSection {
height: 100%;
overflow-y: auto; /*instead of scroll*/
width: 110%;
padding: 20px; /*add padding here*/
}
.section {
background-color: rgba(51,51,51,0.5);
border-radius: 5px;
display: inline-block;
margin: 1%;
height: 100%; /*It does not seem to work without specifying a height.*/
max-height: 42%;
min-height: 42%;
overflow: hidden;
padding: 1%;
vertical-align: top;
width: 28%;
}
I have a website that I'm designing to be responsive to work on various browsers and devices, most of my content is set with widths to either auto or 100%. However my elements aren't exactly centered as the website includes the width under the scrollbar. I want the width to the available room that you can see, so that my website will center properly.
For example my navbar is correctly aligned on the left, but not the right side of the page. Here is the CSS for my navbar, I have LI bullets that make up the options in the HTML.
#header {
border: 2px solid black;
border-top: none;
background-color: #FFFFFF;
height: 2.75em;
left: 0px;
right: 0px;
width: 100%;
z-index: 1;
position: fixed;
margin-top: -2.55em;
}
#navbar {
position: relative;
text-align: center;
right: 0px;
left: 0px;
width: auto;
display: inline;
}
ul {
left: 0px;
right: 0px;
top: 0px;
}
li {
display: inline;
text-align: center;
width: auto;
padding-left: 5em;
padding-right: 5em;
}
Please try this : http://jsfiddle.net/sqp4nfg5/1/
and css :
body { margin:0; padding:0
}
#header {
background-color: #777;
color: #fff;
float: left;
width: 100%;
z-index: 1;
}
#navbar {
float: left;
width: 100%;
}
ul { margin:0; padding:0
}
li {
float: left;
padding-left: 2%;
padding-right: 2%;
text-align: center;
height:35px; line-height:35px; list-style:none;
}
.center_div{float:left; width:100%; }
.center_div div{width:90%; margin:0 auto; overflow:hidden; border:1px solid lightpink; padding:1% 2%}
I'm kind of new to HTML and CSS. I have a nav bar that I want (the logo and links) aligned to being above the sidebar on my page. It's in different positions on different screens (and when browser is resized) and I don't know how to fix it. I made a fiddle thing and I'll link to the site so that you will know what I mean.
This is the fiddle: The Fiddle
This is the page: The page
#header {
width: 100%;
height: 91px;
margin: 0;
top: 0;
}
#menu {
float: right;
width: 100%;
height: 54px;
margin-top: 0;
background: #ffffff url(http://i1378.photobucket.com/albums/ah105/WinPhanNick/menu_bar_zps6212d723.jpg) repeat-x left top;
position: fixed;
}
#menu ul {
margin: 0;
padding: 0px 0 0;
list-style: none;
line-height: normal;
margin-left: 28%;
}
#menu li {
display: inline;
text-align: center;
}
#menu a {
display: block;
float: left;
height: 36px;
padding: 18px 20px 0px 20px;
text-decoration: none;
text-align: center;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #ffffff;
}
li#logo {
height: 52px;
width: 52px;
background: url(http://i1378.photobucket.com/albums/ah105/WinPhanNick/cb_logo_zpsd1b14443.png) no-repeat;
margin-top: 1px;
margin-right: 1px;
margin-left: 1px;
}
#menu a:hover,
#menu .active a {
background: #1687ef;
color: #FFFFFF;
}
#logo {
float: left;
width: 270px;
height: 76px;
margin: 0px;
padding: 15px 0px 0px;
margin-left: 27%;
}
Make your link wrapper (which is the ul) the same width as your page container (which is 892px) and set it to margin: auto to center it. You can remove the margin-left: 28% as well. That's not needed. You also have a float issue so your ul is collapsed. You need to clear your floated elements. You can add overflow:hidden.
#menu ul{
overflow: hidden; //clear float issue
width: 892px; // same width as #page
margin: 0 auto; //will center
padding: 0px 30px; //add to keep the same padding as #page-bgtop
}
FIDDLE
When I re-size the footer, i.e. make the window browser smaller the page gives me the option to scroll. However, when I scroll the background image of the footer does not display past the original window, leaving a huge white gap...
This is the original footer - no edits
Minimizing the browser shows scrolling (which is fine)
If I then scroll, the background does not render...
HTML:
<div id="footerfix" class="grid_12">
<div id="insidefooterfix" class="grid_12margin">
</div>
</div>
CSS:
#footerfix {
color: #C9C9C9;
width: 100%;
background-color: #2d2d2d;
list-style: none;
height: 460px;
padding-bottom: 0;
background-image:url(http://i.imgur.com/yb7j6PD.png);
background-repeat:repeat;
}
#insidefooterfix {
margin-top: 20px;
text-align: center;
height: 380px;
margin-bottom: 0;
}
.grid_12margin {
display:inline;
float: left;
position: relative;
margin-left: 1%;
margin-right: 1%;
}
.grid_12 {
display:inline;
float: left;
position: relative;
/*margin-left: 1%;
margin-right: 1%;*/
}
.container_12 .grid_12 {
width:100%;
/*width:98.0%;*/
}
Code here (simplified without information but all CSS): http://jsfiddle.net/UVvM2/ (but doesn't show any problems here?)
Here is FULL which does show problem: http://jsfiddle.net/UVvM2/2/
The 100% width is relative to your screen, try to add the background-color in your body :
<body clas="gray-bg">
<div id = "footer-fix"> , etc .
CSS :
.gray-bg{
background-color:#2D2D2D;
}
Looking likes see this Below link..
Reference link
#insidefooterfix, #disclaimerfix {
width: 960px;
max-width: 100%;
margin-right: auto;
}
#footerfix {
color: #C9C9C9;
width: 100%;
background-color: #2d2d2d;
list-style: none;
height: 460px;
padding-bottom: 0;
background-image:url(../img/index/footer/pixelpatterns.png);
background-repeat:repeat;
}
#insidefooterfix {
display: block;
float: none;
margin: 20px auto;
text-align: center;
height: 380px;
}
/*settings for social media buttons*/
#insidefooterfixtermsplusbuttons li {
display: inline;
color: #C9C9C9;
}
#insidefooterfixone h5, #insidefooterfixtwo h5, #insidefooterfixthree h5, #insidefooterfixfour h5 {
text-align:left;
margin-bottom: 0;
color:#FFFFFF;
}
#insidefooterfixone ul, #insidefooterfixtwo ul, #insidefooterfixthree ul, #insidefooterfixfour ul {
list-style: none;
text-align: left;
margin-left: 0;
color: #C9C9C9;
}
#insidefooterfixone li, #insidefooterfixtwo li, #insidefooterfixthree li, #insidefooterfixfour li {
list-style: none;
text-align: left;
margin-left: 0;
color: #C9C9C9;
}
#disclaimerfix {
position: relative;
top: 0px;
font-size: 9px;
text-align: center;
margin: 0 auto;
float: none;
}
#disclaimerfix p {
text-align:center;
color: #C9C9C9;
}
#insidefooterfixone {
position: relative;
top: 0px;
left: 200px;
width: 150px;
}
#insidefooterfixtwo {
position: relative;
top: 0px;
left: 200px;
width: 150px;
}
#insidefooterfixthree {
position: relative;
top: 0px;
left: 200px;
width: 150px;
}
#insidefooterfixfour {
position: relative;
top: 0px;
left: 200px;
width: 150px;
}
.container_12 .grid_12 {
width:100%;
/*width:98.0%;*/
}
.grid_12margin {
display:inline;
float: left;
position: relative;
margin-left: 1%;
margin-right: 1%;
}
.grid_12 {
display:inline;
float: left;
position: relative;
/*margin-left: 1%;
margin-right: 1%;*/
}
Hello I'm having a problem with my layout, when I'm resizing it, it's not filling the whole space. Please check it out here
My sample code:
html, body {
margin: 0;
padding: 0;
height: 100%;
}
p, a, h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
}
.container {
width: 100%;
min-height: 100%;
position: relative;
}
.content {
width: 96%;
max-width: 720px;
min-width: 600px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
.headerWrapper {
position: absolute;
height: 85px;
background: #19A347;
z-index: 9000;
width: 100%;
}
#header {
width: 960px;
margin: 0 auto;
position: relative;
}
.logo {
position: absolute;
}
.logoimg {
display: block;
width: 155px;
height: 85px;
text-indent: -9999px;
}
.globalnav {
float: right;
clear: right;
padding: 8px 8px 0 0;
display: block;
}
.nav-menu {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
.nav-menu li {
display: inline;
}
.nav-menu a {
display: inline-block;
padding: 15px;
margin: 5px;
color: #fff;
font-size: 20px;
text-decoration: none;
}
.nav-menu a:hover {
color: #66C285;
}
#footer {
height: 245px;
background: #1c1c1c;
position: absolute;
bottom:0;
left:0;
width: 100%;
}
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 900px;
overflow: hidden;
}
.cols-container div {
width: 20%;
float: left;
padding: 5px;
margin: 15px;
}
.heading {
font-size: 20px;
color: #fff;
background: #009933;
padding: 5px 0 5px 10px;
}
#footer li, a {
color: #fff;
text-decoration: none;
}
#footer a:hover {
color: #999;
};
I don't know what's making it act like this way. Help is truly appreciated.
You should change the width between header and headerWrapper:
.headerWrapper {
position: absolute;
height: 85px;
background: #19A347;
z-index: 9000;
width: 960px;
}
#header {
width: 100%;
margin: 0 auto;
position: relative;
}
You also should change these rules:
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 900px;
overflow: hidden;
}
.content {
width: 96%;
max-width: 720px;
min-width: 600px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
to the min-width you want:
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 400px;
overflow: hidden;
}
.content {
width: 96%;
max-width: 720px;
min-width: 400px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
JSFIDDLE