Unable to center correctly a div in CSS - css

I am working on this project :
body {
background: #f0f0f0;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
outline: none;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #313131;
font-size: 62.5%;
line-height: 1;
}
/** typography **/
h1 {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 2.5em;
line-height: 1.5em;
letter-spacing: -0.05em;
margin-bottom: 20px;
padding: .1em 0;
color: #444;
position: relative;
overflow: hidden;
white-space: nowrap;
text-align: center;
}
h1:before,
h1:after {
content: "";
position: relative;
display: inline-block;
width: 50%;
height: 1px;
vertical-align: middle;
background: #f0f0f0;
}
h1:before {
left: -.5em;
margin: 0 0 0 -50%;
}
h1:after {
left: .5em;
margin: 0 -50% 0 0;
}
h1 > span {
display: inline-block;
vertical-align: middle;
white-space: normal;
}
h2 {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 2.1em;
line-height: 1.4em;
letter-spacing: normal;
margin-bottom: 20px;
padding: .1em 0;
color: #444;
position: relative;
overflow: hidden;
white-space: nowrap;
text-align: center;
}
p {
display: block;
font-size: 1.4em;
line-height: 1.55em;
margin-bottom: 22px;
color: #555;
}
a { color: #5a9352; text-decoration: none; }
a:hover { text-decoration: underline; }
.center { display: block; text-align: center; }
/** page structure **/
#w {
width: 90%;
margin: 0 auto;
padding-top: 30px;
padding-bottom: 45px;
}
#content {
display: block;
width: 100%;
background: #fff;
padding: 25px 20px;
padding-bottom: 35px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
}
#userphoto {
display: block;
float: right;
margin-left: 10px;
margin-bottom: 8px;
}
#userphoto img {
display: block;
background: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.4);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.4);
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
/** profile nav links **/
#profiletabs {
display: block;
margin-bottom: 4px;
height: 50px;
}
#profiletabs ul { list-style: none; display: block; width: 70%; height: 50px; padding-left: 0;}
#profiletabls ul li { float: left; }
#profiletabs ul li a {
display: block;
float: left;
padding: 8px 11px;
font-size: 1.2em;
font-weight: bold;
background: #eae8db;
color: #666;
margin-right: 7px;
border: 1px solid #fff;
-webkit-border-radius: 5px;
-webkit-border-bottom-left-radius: 0;
-moz-border-radius: 5px;
-moz-border-radius-bottomleft: 0;
border-radius: 5px;
border-bottom-left-radius: 0;
}
#profiletabs ul li a:hover {
text-decoration: none;
background: #dad7c2;
color: #565656;
}
#profiletabs ul li a.sel {
background: #fff;
border-color: #d1cdb5;
}
/** clearfix **/
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
.clearfix { display: inline-block; }
<div id="w">
<div id="content" class="clearfix">
<div id="userphoto"><img src="images/avatar.png" alt="default avatar"></div>
<h1>Minimal User Profile Layout</h1>
<nav id="profiletabs">
<ul class="clearfix">
<li>Projects</li>
<!--<li>Activity</li>
<li>Friends</li>-->
<li>Profile Details</li>
<li>Orders</li>
<li>Add an article</li>
</ul>
</nav>
</div>
</div>
The main content of the page has been inserted in a div named #w. I have applied margin: 0 auto; to #w for it to be centered but it is not working correctly. The margin-left is always bigger than the right side, whenever I try to reduce the margin-left, I end up having something else.
Please let me know How I can fix this problem.

Remove
#content {
width: 100%;
}
Or add
#content {
box-sizing: border-box;
}
By default, the width does not include the padding. So the outer width is bigger.

Try this :
add box-sizing property in #content
#content{
box-sizing: border-box; // ADD this
display: block;
width: 100%;
background: #fff;
padding: 25px 20px;
padding-bottom: 35px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
}

This is because your #userphoto is overlapping you <h1> check this out with position:absolute on #userphoto.
body {
background: #f0f0f0;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
outline: none;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #313131;
font-size: 62.5%;
line-height: 1;
}
/** typography **/
h1 {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 2.5em;
line-height: 1.5em;
letter-spacing: -0.05em;
margin-bottom: 20px;
padding: .1em 0;
color: #444;
position: relative;
overflow: hidden;
white-space: nowrap;
text-align: center;
}
h1:before,
h1:after {
content: "";
position: relative;
display: inline-block;
width: 50%;
height: 1px;
vertical-align: middle;
background: #f0f0f0;
}
h1:before {
left: -.5em;
margin: 0 0 0 -50%;
}
h1:after {
left: .5em;
margin: 0 -50% 0 0;
}
h1 > span {
display: inline-block;
vertical-align: middle;
white-space: normal;
}
h2 {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 2.1em;
line-height: 1.4em;
letter-spacing: normal;
margin-bottom: 20px;
padding: .1em 0;
color: #444;
position: relative;
overflow: hidden;
white-space: nowrap;
text-align: center;
}
p {
display: block;
font-size: 1.4em;
line-height: 1.55em;
margin-bottom: 22px;
color: #555;
}
a { color: #5a9352; text-decoration: none; }
a:hover { text-decoration: underline; }
.center { display: block; text-align: center; }
/** page structure **/
#w {
width: 90%;
margin: 0 auto;
padding-top: 30px;
padding-bottom: 45px;
}
#content {
display: block;
width: 100%;
background: #fff;
padding: 25px 20px;
padding-bottom: 35px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 0px;
}
#userphoto {
display: block;
position: absolute;
right: 0;
margin-left: 10px;
margin-bottom: 8px;
}
#userphoto img {
display: block;
background: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.4);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.4);
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
/** profile nav links **/
#profiletabs {
display: block;
margin-bottom: 4px;
height: 50px;
}
#profiletabs ul { list-style: none; display: block; width: 70%; height: 50px; padding-left: 0;}
#profiletabls ul li { float: left; }
#profiletabs ul li a {
display: block;
float: left;
padding: 8px 11px;
font-size: 1.2em;
font-weight: bold;
background: #eae8db;
color: #666;
margin-right: 7px;
border: 1px solid #fff;
-webkit-border-radius: 5px;
-webkit-border-bottom-left-radius: 0;
-moz-border-radius: 5px;
-moz-border-radius-bottomleft: 0;
border-radius: 5px;
border-bottom-left-radius: 0;
}
#profiletabs ul li a:hover {
text-decoration: none;
background: #dad7c2;
color: #565656;
}
#profiletabs ul li a.sel {
background: #fff;
border-color: #d1cdb5;
}
/** clearfix **/
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
.clearfix { display: inline-block; }
<div id="w">
<div id="content" class="clearfix">
<div id="userphoto"><img src="images/avatar.png" alt="default avatar"></div>
<h1>Minimal User Profile Layout</h1>
<nav id="profiletabs">
<ul class="clearfix">
<li>Projects</li>
<!--<li>Activity</li>
<li>Friends</li>-->
<li>Profile Details</li>
<li>Orders</li>
<li>Add an article</li>
</ul>
</nav>
</div>
</div>

Related

flex box parent wrappers do not fill height of the page

Here is my JSFiddle...https://jsfiddle.net/5xt7pt7f/
I get that there is a lot going on here, I will try to isolate my issue as best as possible.
There are two parent wrappers...
<div class="video-section">
...
<div class="chat-section">
As you can see in the fiddle, their height is not 100%, it seems to have some sort of max-height because they do not always fill the page. My html structure is something like...
<div id="app">
...
<div class="chat-navbar">....</div>
<div class="chat-wrapper">
<div class="video-section">
<div class="chat-section">
...
#app is the main container. I want .chat-navbar to be at the top and the .chat-wrapper to be below it. I accomplished this through...
div#app {
display: flex;
flex: 1;
flex-direction: column; }
Next I wanted .video-section and .chat-section to be side by side, I accomplished this through...
.chat-wrapper {
display: flex;
flex: 1;
flex-direction: row;
}
However, these two wrappers do not fill the height of the page. I do not care if the canvas elements inside fill the page, but I do need the parent wrappers to fill up the page.
This is what it look like on my local...
As you can see there is a lot of white space at the bottom because the elements do not have full height. I thought flex:1 would have resolved this.
Try using display:flex; on the div containing chat-navbar and chat-wrapper (I gave it id="chatcon") and then use flex-grow:1; on chat-wrapper. I commented one of the canvases and changed navbar color to red, to help notice the difference.
Here's a codepen
body, html {
margin: 0;
font-family: 'Libre Baskerville', serif; }
#chatcon{
min-height:100vh;
display:flex;
flex-direction:column;
}
a {
text-decoration: none;
margin: 5px; }
a:active, a:visited {
color: inherit; }
.chat-wrapper {
display: flex;
flex: 1;
flex-direction: row;
}
.chat-section {
border: none;
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-left: 0.5em;
display: flex;
flex: 1;
flex-direction: column;
margin-left: 5px; }
div#app {
display: flex;
flex: 1;
flex-direction: column; }
.chat-section ul {
overflow-y: auto;
flex: 1;
margin-bottom: 0;
padding-left: 0.5em; }
.chat-section ul li {
text-decoration: none;
list-style-type: none; }
.chat-section ul li + li {
margin-top: 7px; }
.chat-section textarea {
resize: none;
border: none;
border-top: 1px solid #ccc;
box-sizing: border-box;
margin-left: -0.5em; }
.chat-section textarea:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none; }
.video-section {
display: flex;
flex: 1;
text-align: center; }
.videos {
flex: 1;
display: flex;
max-width: 800px;
flex-direction: column;
align-content: stretch; }
.chat-navbar {
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-top: 1em;
display: flex;
flex: 1; }
.localCanvas, .remoteCanvas {
background-color: black;
margin-left: 5px;
margin-right: 5px;
-webkit-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75); }
.localCanvas {
margin-top: 5px;
margin-bottom: 5px; }
canvas.remoteCanvas {
margin-top: 5px; }
.auth-container {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
flex-direction: column;
background: #004FF9;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, #FFF94C, #004FF9);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(to right, #FFF94C, #004FF9);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(to right, #FFF94C, #004FF9);
/* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #FFF94C, #004FF9);
/* Standard syntax */
background-size: cover; }
.loginForm, .registerForm {
width: 500px;
height: 600px;
display: block;
margin-left: auto;
margin-right: auto;
position: absolute;
top: 130px;
left: 0;
right: 0; }
.loginWrap {
width: 500px;
float: left;
height: 100%;
background: rgba(255, 255, 255, 0.75);
-webkit-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75); }
.bodyLogin {
overflow: hidden;
height: 100%; }
.bg_image {
height: 1000px;
width: 100%; }
h1 {
font-family: 'Roboto', sans-serif;
color: #87909c;
font-weight: bolder;
text-align: center;
font-size: 1.5em;
margin-top: 20px; }
img.logo_image {
width: 500px; }
img.title_image {
width: 200px;
margin-left: auto;
display: block;
margin-right: auto;
margin-top: -90px; }
label {
font-size: 12px;
font-weight: bold;
color: #87909c;
float: left;
clear: both;
font-family: 'Roboto', sans-serif;
margin-left: 30px;
margin-top: 15px; }
input[type="text"], input[type="password"] {
float: left;
margin-top: 15px;
clear: both;
margin-left: 30px;
font-size: 1.3em;
width: 80%;
outline: none;
border: none;
padding: 10px;
padding-left: 10px; }
.login_btn, .register_btn {
float: left;
clear: left;
font-family: 'Roboto', sans-serif;
background: #7289da;
border: solid 1px #7289da;
width: 84%;
margin-left: 30px;
margin-top: 50px;
padding: 20px;
border-radius: 5px;
font-size: 1em;
color: white;
cursor: pointer; }
.registerLinkWrap, .loginLinkWrap {
float: left;
clear: left;
margin-left: 30px; }
a.register_link, a.login_link {
float: left;
margin-top: 11px;
font-size: 13px;
color: black;
font-family: 'Roboto', sans-serif; }
a.register_link:hover, a.login_link:hover {
text-decoration: underline; }
p.register_sentence, p.login_sentence {
clear: left;
float: left;
font-size: 12px;
color: #3e4956;
font-family: 'Roboto', sans-serif; }
.errUsername, .errPassword, .errRegister {
float: left;
margin-left: 30px;
margin-top: 3px;
color: red;
font-size: 0.8em;
font-family: 'Roboto', sans-serif; }
.reg_success {
position: absolute;
background: #f2fae3;
width: 100%;
text-align: center;
padding: 10px;
font-family: 'Roboto', sans-serif;
color: #94b639;
border-bottom: solid 3px #94b639; }
.reg_neutral {
display: none; }
/*# sourceMappingURL=styles.css.map*/
.chat-navbar{
flex-shrink:0;
flex-grow:0;
height:70px;
background-color:red;
}
<div id="app">
<div id="chatcon" data-reactroot="">
<div class="chat-navbar">
Logout
</div>
<div class="chat-wrapper">
<div class="video-section">
<div class="videos">
<canvas class="remoteCanvas" width="320" height="240"></canvas>
<!-- <canvas class="localCanvas" width="320" height="240"></canvas> -->
</div>
</div>
<div class="chat-section">
<ul>No messages</ul>
<textarea placeholder="Type a message" rows="2"></textarea>
</div>
</div></div></div>
To simplify your requirement, add relative heights wherever required so that your wrappers occupy the entirety of the page.
Give html, body { height: 100%; } which resolves the majority of issues and then further on.
Created a fiddle for you: https://jsfiddle.net/nashcheez/u7bmL0nm/
body,
html {
margin: 0;
font-family: 'Libre Baskerville', serif;
height: 100%;
}
a {
text-decoration: none;
margin: 5px;
}
a:active,
a:visited {
color: inherit;
}
.chat-wrapper {
display: flex;
flex: 1;
flex-direction: row;
height: 100%;
}
.chat-section {
border: none;
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-left: 0.5em;
display: flex;
flex: 1;
flex-direction: column;
margin-left: 5px;
}
div#app {
display: flex;
flex: 1;
flex-direction: column;
height: 100%;
}
.chat-section ul {
overflow-y: auto;
flex: 1;
margin-bottom: 0;
padding-left: 0.5em;
}
.chat-section ul li {
text-decoration: none;
list-style-type: none;
}
.chat-section ul li + li {
margin-top: 7px;
}
.chat-section textarea {
resize: none;
border: none;
border-top: 1px solid #ccc;
box-sizing: border-box;
margin-left: -0.5em;
}
.chat-section textarea:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.video-section {
display: flex;
flex: 1;
text-align: center;
}
.videos {
flex: 1;
display: flex;
max-width: 800px;
flex-direction: column;
align-content: stretch;
}
.chat-navbar {
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-top: 1em;
display: flex;
flex: 1;
}
.localCanvas,
.remoteCanvas {
background-color: black;
margin-left: 5px;
margin-right: 5px;
-webkit-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
height: 50%;
}
.localCanvas {
margin-top: 5px;
margin-bottom: 5px;
}
canvas.remoteCanvas {
margin-top: 5px;
}
.auth-container {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
flex-direction: column;
background: #004FF9;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, #FFF94C, #004FF9);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(to right, #FFF94C, #004FF9);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(to right, #FFF94C, #004FF9);
/* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #FFF94C, #004FF9);
/* Standard syntax */
background-size: cover;
}
.loginForm,
.registerForm {
width: 500px;
height: 600px;
display: block;
margin-left: auto;
margin-right: auto;
position: absolute;
top: 130px;
left: 0;
right: 0;
}
.loginWrap {
width: 500px;
float: left;
height: 100%;
background: rgba(255, 255, 255, 0.75);
-webkit-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
}
.bodyLogin {
overflow: hidden;
height: 100%;
}
.bg_image {
height: 1000px;
width: 100%;
}
h1 {
font-family: 'Roboto', sans-serif;
color: #87909c;
font-weight: bolder;
text-align: center;
font-size: 1.5em;
margin-top: 20px;
}
img.logo_image {
width: 500px;
}
img.title_image {
width: 200px;
margin-left: auto;
display: block;
margin-right: auto;
margin-top: -90px;
}
label {
font-size: 12px;
font-weight: bold;
color: #87909c;
float: left;
clear: both;
font-family: 'Roboto', sans-serif;
margin-left: 30px;
margin-top: 15px;
}
input[type="text"],
input[type="password"] {
float: left;
margin-top: 15px;
clear: both;
margin-left: 30px;
font-size: 1.3em;
width: 80%;
outline: none;
border: none;
padding: 10px;
padding-left: 10px;
}
.login_btn,
.register_btn {
float: left;
clear: left;
font-family: 'Roboto', sans-serif;
background: #7289da;
border: solid 1px #7289da;
width: 84%;
margin-left: 30px;
margin-top: 50px;
padding: 20px;
border-radius: 5px;
font-size: 1em;
color: white;
cursor: pointer;
}
.registerLinkWrap,
.loginLinkWrap {
float: left;
clear: left;
margin-left: 30px;
}
a.register_link,
a.login_link {
float: left;
margin-top: 11px;
font-size: 13px;
color: black;
font-family: 'Roboto', sans-serif;
}
a.register_link:hover,
a.login_link:hover {
text-decoration: underline;
}
p.register_sentence,
p.login_sentence {
clear: left;
float: left;
font-size: 12px;
color: #3e4956;
font-family: 'Roboto', sans-serif;
}
.errUsername,
.errPassword,
.errRegister {
float: left;
margin-left: 30px;
margin-top: 3px;
color: red;
font-size: 0.8em;
font-family: 'Roboto', sans-serif;
}
.reg_success {
position: absolute;
background: #f2fae3;
width: 100%;
text-align: center;
padding: 10px;
font-family: 'Roboto', sans-serif;
color: #94b639;
border-bottom: solid 3px #94b639;
}
.reg_neutral {
display: none;
}
<div id="app">
<div style="height: 100%;" data-reactroot="">
<div class="chat-navbar">
Logout
</div>
<div class="chat-wrapper">
<div class="video-section">
<div class="videos">
<canvas class="remoteCanvas" width="320" height="240"></canvas>
<canvas class="localCanvas" width="320" height="240"></canvas>
</div>
</div>
<div class="chat-section">
<ul>No messages</ul>
<textarea placeholder="Type a message" rows="2"></textarea>
</div>
</div>
</div>
</div>
I see that you gave div#app both display: flex and flex: 1. Do note that the flex: 1 does not do anything here, it is a flex child property.
So for div#app to fill page it need a height, here given min-height: 100vh. Now you can give for example the <div data-reactroot> element flex: 1 to fill its parent (light blue).
Any child having a parent with display: flex; flex-direction: column only need flex: 1 to fill vertical space, if it has flex-direction: row it will need a height, where height: 100% normally work.
These 2 rules shows how to
div#app {
display: flex;
flex-direction: column;
min-height: 100vh;
}
div[data-reactroot] {
flex: 1;
background: lightblue;
}
Hope this makes it clear how it works, and from here you can apply the same logic your way down in the markup.
body,
html {
margin: 0;
font-family: 'Libre Baskerville', serif;
}
a {
text-decoration: none;
margin: 5px;
}
a:active,
a:visited {
color: inherit;
}
.chat-wrapper {
display: flex;
flex: 1;
flex-direction: row;
}
.chat-section {
border: none;
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-left: 0.5em;
display: flex;
flex: 1;
flex-direction: column;
margin-left: 5px;
}
div#app {
display: flex;
flex-direction: column;
min-height: 100vh;
}
div[data-reactroot] {
flex: 1;
background: lightblue;
}
.chat-section ul {
overflow-y: auto;
flex: 1;
margin-bottom: 0;
padding-left: 0.5em;
}
.chat-section ul li {
text-decoration: none;
list-style-type: none;
}
.chat-section ul li + li {
margin-top: 7px;
}
.chat-section textarea {
resize: none;
border: none;
border-top: 1px solid #ccc;
box-sizing: border-box;
margin-left: -0.5em;
}
.chat-section textarea:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.video-section {
display: flex;
flex: 1;
text-align: center;
}
.videos {
flex: 1;
display: flex;
max-width: 800px;
flex-direction: column;
align-content: stretch;
}
.chat-navbar {
border-left: 1px solid #ccc;
box-sizing: border-box;
padding-top: 1em;
display: flex;
flex: 1;
}
.localCanvas,
.remoteCanvas {
background-color: black;
margin-left: 5px;
margin-right: 5px;
-webkit-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
box-shadow: 9px 5px 17px -6px rgba(0, 0, 0, 0.75);
}
.localCanvas {
margin-top: 5px;
margin-bottom: 5px;
}
canvas.remoteCanvas {
margin-top: 5px;
}
.auth-container {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
flex-direction: column;
background: #004FF9;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, #FFF94C, #004FF9);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(to right, #FFF94C, #004FF9);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(to right, #FFF94C, #004FF9);
/* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #FFF94C, #004FF9);
/* Standard syntax */
background-size: cover;
}
.loginForm,
.registerForm {
width: 500px;
height: 600px;
display: block;
margin-left: auto;
margin-right: auto;
position: absolute;
top: 130px;
left: 0;
right: 0;
}
.loginWrap {
width: 500px;
float: left;
height: 100%;
background: rgba(255, 255, 255, 0.75);
-webkit-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
box-shadow: 4px 3px 14px -5px rgba(0, 0, 0, 0.75);
}
.bodyLogin {
overflow: hidden;
height: 100%;
}
.bg_image {
height: 1000px;
width: 100%;
}
h1 {
font-family: 'Roboto', sans-serif;
color: #87909c;
font-weight: bolder;
text-align: center;
font-size: 1.5em;
margin-top: 20px;
}
img.logo_image {
width: 500px;
}
img.title_image {
width: 200px;
margin-left: auto;
display: block;
margin-right: auto;
margin-top: -90px;
}
label {
font-size: 12px;
font-weight: bold;
color: #87909c;
float: left;
clear: both;
font-family: 'Roboto', sans-serif;
margin-left: 30px;
margin-top: 15px;
}
input[type="text"],
input[type="password"] {
float: left;
margin-top: 15px;
clear: both;
margin-left: 30px;
font-size: 1.3em;
width: 80%;
outline: none;
border: none;
padding: 10px;
padding-left: 10px;
}
.login_btn,
.register_btn {
float: left;
clear: left;
font-family: 'Roboto', sans-serif;
background: #7289da;
border: solid 1px #7289da;
width: 84%;
margin-left: 30px;
margin-top: 50px;
padding: 20px;
border-radius: 5px;
font-size: 1em;
color: white;
cursor: pointer;
}
.registerLinkWrap,
.loginLinkWrap {
float: left;
clear: left;
margin-left: 30px;
}
a.register_link,
a.login_link {
float: left;
margin-top: 11px;
font-size: 13px;
color: black;
font-family: 'Roboto', sans-serif;
}
a.register_link:hover,
a.login_link:hover {
text-decoration: underline;
}
p.register_sentence,
p.login_sentence {
clear: left;
float: left;
font-size: 12px;
color: #3e4956;
font-family: 'Roboto', sans-serif;
}
.errUsername,
.errPassword,
.errRegister {
float: left;
margin-left: 30px;
margin-top: 3px;
color: red;
font-size: 0.8em;
font-family: 'Roboto', sans-serif;
}
.reg_success {
position: absolute;
background: #f2fae3;
width: 100%;
text-align: center;
padding: 10px;
font-family: 'Roboto', sans-serif;
color: #94b639;
border-bottom: solid 3px #94b639;
}
.reg_neutral {
display: none;
}
/*# sourceMappingURL=styles.css.map*/
<div id="app">
<div data-reactroot="">
<div class="chat-navbar">
Logout
</div>
<div class="chat-wrapper">
<div class="video-section">
<div class="videos">
<canvas class="remoteCanvas" width="320" height="240"></canvas>
<canvas class="localCanvas" width="320" height="240"></canvas>
</div>
</div>
<div class="chat-section">
<ul>No messages</ul>
<textarea placeholder="Type a message" rows="2"></textarea>
</div>
</div>
</div>
</div>

Having trouble once I added iframe

This is sort of the same issue I asked here: Cannot get two CSS elements to be next to each other
However, this time, it's messing up when I added an iframe. I tried applying different styles, even to the iframe, but it doesn't appear to be working. I also messed with the CSS of the ul and li that I added to the side nav bar (didn't help, though changing the ul property to display: table-row; did fix another issue I had with something else.)
My main plan was to have an iframe to another group of pages. (My restaurant pages might have more than one tab for each restaurant, but I had been wondering how to have a "back" thing to my ski resort (where the restaurants are) so the user could go back to them. I then thought, why not just have an iframe instead?
However, once I added the iframe, the trouble I had before (see previous stack overflow link above) suddenly came back.
main.css:
#logo
{
border: 1px dashed purple;
width: 1050;
height: 75;
}
#logo > img
{
width: 1050;
height: 75;
}
.floatleft
{
float: left;
}
.floatright
{
float: right;
}
#content
{
border-left: 3px solid #283379;
border-right: 3px solid #283379;
text-align: left;
margin: 0 auto;
width: 960px;
background-color: #ffffff;
background-repeat: repeat-y;
height: 800;
}
nav
{
border: 10px solid transparent;
padding: 15px;
border-image-source: url(./blue-diamond.gif);
border-image-repeat:repeat;
border-image-slice: 30;
background-color: 2211ff;
font-family: "Impact", Times, serif;
font-size: 110%;
}
nav#vert
{
width: 220px;
height: 540px;
margin: 0px;
display:table-cell;
}
body {
color: #000000;
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
background-color: #422520;
background-image: url(./snow_mountain.jpg);
background-repeat:no-repeat;
background-size:cover;
text-align: center;
background-attachment: fixed;
background-position: center;
}
#footerContainer
{
border-left: 3px solid #283379;
border-right: 3px solid #283379;
text-align: left;
margin: 0 auto;
width: 980px;
background-color: #ffffff;
background-repeat: repeat-y;
}
footer
{
border: 10px solid transparent;
padding: 15px;
text-align: left;
margin: 0 auto;
width: 1000px;
background-repeat: repeat-y;
border-image-source: url(./blue-diamond.gif);
border-image-repeat:repeat;
border-image-slice: 30;
background-color: 2211ff;
font-family: "Impact", Times, serif;
font-size: 14px;
color: white;
}
footer > a
{
color: white;
font-family: "Impact", Times, serif;
font-size: 14px;
}
#container
{
border-left: 3px solid #283379;
border-right: 3px solid #283379;
text-align: left;
margin: 0 auto;
width: 1050px;
background-color: #ffffff;
background-repeat: repeat-y;
height: 750px;
}
nav > a
{
color: #ccccff;
}
nav#hor > div
{
border: 1px solid white;
float: left;
padding: 10px;
background-color: #000044;
}
nav#hor
{
width: 1000px;
height: 50px;
margin: 0;
font-size: 110%;
}
nav#hor a
{
color: rgb(0 0,238);
}
nav#hor > div > a
{
color: #ccccff;
text-decoration: none;
font-size: 100%;
}
nav#hor>div:hover
{
background-color: #018802;
}
h1
{
font-family: "MV Boli", Times, Serif;
font-style: bold;
text-align: center;
font-size: 36px;
}
h2
{
font-family: "MV Boli", Times, Serif;
font-style: bold;
text-align: center;
font-size: 26px;
}
h3
{
font-family: "MV Boli", Times, Serif;
font-style: bold;
text-align: center;
font-size: 20px;
}
#text-container
{
border: 2px solid cyan;
width: 1005px;
height: 690px;
*/ zoom: 1;
*/ margin: 0;
display: table-cell;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
}
#text-container:after
{
clear: both;
content: ".";
display: block;
height: 0;
visibility:hidden;
}
#text-container > p
{
font-family: "Myriad Web Pro", Times, Serif;
font-size: 18px;
}
.left img
{
float: left;
padding: 0 20px 20px 0;
}
.left > p
{
font-family: "Myriad Web Pro", Times, Serif;
font-size: 18px;
}
.right img
{
float: right;
margin: 0px 0px 15px 20px;
border: 1px solid transparent;
}
.right > p
{
font-family: "Myriad Web Pro", Times, Serif;
font-size: 18px;
}
nav#hor ul
{
list-style-type: none;
margin: 0;
padding: 0;
overflow: auto;
background-color: #000044;
}
nav#hor ul li:hover
{
background-color: #018802;
}
nav#vert ul
{
list-style-type: none;
margin: 0;
padding: 0;
overflow: auto;
background-color: #000044;
display: table-row;
}
nav#hor li
{
float: left;
border: 1px solid white;.
}
nav#vert li
{
float: left;
border: 1px solid white;.
}
nav#vert li a, .dropbtn {
display: inline-block;
// color: white;
text-align: center;
padding: 8px 8px;
text-decoration: none;
}
nav#hor li a, .dropbtn {
display: inline-block;
// color: white;
text-align: center;
padding: 8px 8px;
text-decoration: none;
}
nav#hor li a:hover, .dropdown:hover .dropbtn {
background-color: #018802;
}
nav#vert li a:hover, .dropdown:hover .dropbtn {
background-color: #018802;
}
li.dropdown {
display: inline-block;
}
.dropdown-content ul li
{
width: 100%;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
color: rgb(0, 0, 238);
z-index: 1;
}
#eAndADropdown
{
}
#restaurantDropdown li
{
background-color: #000044;
border: 1px solid white;
}
#restaurantDropdown ul
{
border: 1px solid white;
}
#restaurantDropdown:hover
{
background-color: #018802;
}
#restaurantDropdown a
{
color: rgb(0, 0, 238);
}
.dropdown-content a {
color: rgb(0, 0, 238);
border: 1 px solid white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.show {display:block;}
li a
{
color: rgb(0, 0, 238);
}
testingMongoose.php
<html>
<head>
<title> The Mountains </title>
<link rel="stylesheet" type="text/css" href="./main.css">
<link rel="icon" href="./ski_icon.png">
<script src="jquery-3.0.0.min.js" type="text/javascript"></script>
<script>
$( document ).ready(function() {
$("#container").css("height", 800);
});
</script>
</head>
<body>
<?php include 'topandside.php';?>
<div id="text-container">
<iframe src="./index.php" width=700; height=620;></iframe>
</div>
</div>
</div>
<?php include 'footer.php';?>
</div>
</body>
</html>
This time, having display: table-cell; for both nav#vert and #text-content doesn't appear to be enough like it was before.
float: left on the nav#vert seems to have fixed that issue, though it broke some other things (though I should be able to fix those.)

Content Jumps When Loading Page

Whenever I load my page, the content area for the product jumps to position (shifts downwards) and so do the social media icons in the footer. You'll see this happen if you refresh the page or simply click on either of the product categories on the left or the navigation links in the fixed footer.
This is happening predominately in Safari. I'm running 8.0.7 on Mac OS X 10.10.4 (Yosemite). Firefox 45.0.2 seems ok. Chrome 50.0.2661.86 acts a little weird with the icons flashing and copyright text, so I believe that has the same issue though the load time may be quicker.
I've looked at my CSS, but I can't fathom why it's doing it(?). I'm really stuck and realise it's perhaps something simple I'm overlooking. Driving me loopy! :-(
A friend told me it has something to do with the floats for the catalogue_wrapper_right, it shouldn't be there. That's for the content. And, I'm not sure again for the footer. Help much appreciated to get this fixed.
The product content text is being populated using PHP from my database.
The key elements here to look at are catalogue_wrapper and catalogue_wrapper_right for the content, and then container and social for the footer div blocks.
Thanks.
CSS:
/* ===============================
Author: Ashley Smith
Date: July 11, 2015
Notes:
Colour Palette:
---------------
Light Cream: #f2f3ee
Orange: #d17f38
Yellow: #e8c04f
Brown: #4b2707
=============================== */
/* General */
body {
background: url('../images/wood 4.jpg') top left no-repeat; top no-repeat; background-attachment: fixed;
background-size: 100% 100%;
color: black;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
font-size: 14px;
font-family: 'Open Sans', "Helvetica Neue", Arial, sans-serif;
}
.container {
width: 1280px;
margin: 0 auto;
padding: 30px 24px;
background: white;
-webkit-box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
-moz-box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
clear: both;
}
/* Typography */
p {
margin: 0;
padding: 0;
}
a {
text-transform: uppercase;
text-decoration: none;
list-style: none;
padding: 0px 10px;
font-weight: bold;
color: black;
margin: 0;
}
/* Header */
header.main{
background: white;
padding: 10px;
margin-top: -30px;
margin-bottom: -30px;
height: 141px;
}
header nav {
text-align: center;
}
header nav ul {
margin: 0;
padding: 0;
list-style: none;
display: inline-block;
line-height: 141px;
}
header nav ul li {
display: inline-block;
padding: 0 20px;
}
header nav ul li a {
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
}
header nav ul li#logo a {
display: block;
width: 200px;
height: 150px;
padding: 0;
background: url('../images/LogoM.svg') center center no-repeat;
background-size: 300px;
}
header nav ul li#logo a p {
opacity: 0;
}
/* Small Basket */
#small_basket {
width: 200px;
margin-bottom: 20px;
}
#basket_left dt {
clear: left;
width: 170px;
}
#basket_left {
margin-top: 30px;
margin-bottom: 0;
}
#basket_left dd {
text-align: right;
width: 150px;
margin-bottom: 15px;
}
#basket_left, #basket_left dd, #basket_left dt {
float: left;
}
#basket_left dd.bl_ti, #basket_left dd.bl_st, #basket_left dd.bl_vat, #basket_left dd.bl_total {
display: block;
width: 0px;
padding: 0;
clear: all;
margin-left: 0px;
}
.your_bas {
width: 200px;
border-bottom: dashed 1px #aaa;
padding-bottom: 9px;
}
.check_button {
border-bottom: dashed 1px #aaa;
}
.check_button, .check_button a {
clear: left;
padding: 0px 0px 14px 0px;
font-style: normal;
font-size: 14px;
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
font-weight: normal;
text-transform: none;
}
.red {
color: red;
}
span.cart_pic {
background: url('../images/cart.png') center center no-repeat;
display: inline-block;
position: relative;
top: 10px;
left: 15px;
width: 30px;
height: 30px;
}
/* Store Content Styling */
#wrapper {
width: 1280px;
text-align:left;
margin:0 auto;
padding: 14px 0;
}
#outer {
width: 1280px;
margin: 0 auto;
padding: 30px 24px;
background: white;
-webkit-box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
-moz-box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
box-shadow: 0px 0px 19px 0px rgba(0,0,0,1);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
#cat_left {
width: 150px;
}
#cat_left p {
font-size: 20px;
margin: -5px;
font-weight: 300;
text-indent: 5px;
}
#cat_right {
margin-left: 147px;
width: 900px
}
#cat_navigation {
margin-top: 20px;
margin-bottom: 14px;
width: 200px;
line-height: 35px;
list-style: none;
border-top: dashed 1px #aaa;
padding: 0;
float: left;
}
#cat_navigation li {
float: left;
background-color: rgba(209,209,209,0.4);
text-align: center;
width: 100%;
padding: 2px;
margin-bottom: 10px;
}
#cat_navigation li a {
width: 150px;
opacity: 0.2;
font-size: 14px;
font-weight: 300;
padding: 0;
}
#cat_navigation li a.act {
opacity: 1;
font-weight: 700;
}
#cat_prod {
border-bottom: dashed 1px #aaa;
margin-bottom: 0;
padding-bottom: 14px;
}
#cat_prod h1 {
font-size: 20px;
margin: -5px;
margin-bottom: 1px;
font-weight: 300;
}
/* Catalogue Styling For Products Alignment... Continued */
.catalogue_wrapper {
width:100%;
border-bottom: dashed 1px #aaa;
height: 100%;
display: block;
clear: both;
position: static;
}
.catalogue_wrapper_left {
display: inline-block;
width: 120px;
margin-top: 20px;
}
.catalogue_wrapper_right {
display: block;
width: 750px;
position: relative;
left: 150px;
height: 180px;
margin-top: -120px;
margin-bottom: -40px;
}
.catalogue_wrapper_right h4 a {
padding: 0;
font-size: 20px;
}
.catalogue_wrapper_left a img {
width: 120px;
height: 150px;
}
.catalogue_wrapper_left a {
padding: 0;
}
/* Catalaogue Floats */
#cat_left, #cat_right, #catalogue_wrapper, #catalogue_wrapper_left, #catalogue_wrapper_right {
float: left;
}
/* Catalogue Products Pages */
.catalogue_wrapper_product_right {
font-size: 20px;
font-weight: bold;
text-transform: uppercase;
display: block;
width: 750px;
position: relative;
left: 150px;
height: 180px;
margin-top: -70px;
margin-bottom: -40px;
}
.product_info {
font-size: 14px;
display: block;
width: 750px;
text-transform: none;
top: -63px;
}
/* Buttons */
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/* Basket and Checkout Buttons */
.sbm, .btn {
vertical-align: middle;
cursor: pointer;
display:block;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
.sbm_blue {
background: transparent;
background-color: #43a9d9;
border-radius: 4px;
border: none;
padding: 10px 15px;
}
.btn {
text-transform: uppercase;
background: transparent;
background-color: #43a9d9;
border: none;
border-radius: 4px;
color: white;
}
#btn_login {
text-transform: uppercase;
border-radius: 4px;
background: transparent;
background-color: #43a9d9;
border: none;
color: white;
padding: 0px 15px;
}
#btn {
text-transform: uppercase;
background-color: #43a9d9;
border-radius: 4px;
color: white;
padding: 0px 15px;
}
.fl_l {
float: left;
}
.fl_r {
float: right;
}
/* Basket Button */
.add_to_basket {
padding: 6px 12px;
text-transform: uppercase;
background-color: #43a9d9;
border-radius: 4px;
color: white;
}
/* Basket Page */
.ta_r, th.ta_r, .td.ta_r {
text-align: right;
padding: 10px;
}
.ta_left {
text-align: left;
padding: 10px;
}
.ta_right {
text-align: right;
padding: 10px 0px;
}
.col_15 {
width: 15%
}
.tbl_repeat {
width: 900px;
margin-top: 25px;
}
.ta_left_name {
text-align: left;
padding: 10px;
width: 650px;
}
.ta_left_qty input {
width: 40px;
}
.ta_r a {
padding: 0;
text-transform: none;
}
.fld_qty {
border: solid 1px #aaa
}
.fld_qty {
width: 30px;
text-align: right;
padding: 0
}
/* Checkout Page */
.tbl_insert {
margin-bottom:14px;
width: 900px;
line-height: 34.5px;
}
.tbl_insert td {
padding:3px;
}
.tbl_insert th {
padding: 3px 10px 3px 0;
width: 170px;
font-weight: normal;
vertical-align: top;
}
.fld {
width: 700px;
}
.warn {
display: block;
color: #900;
padding: 0;
vertical-align: text-bottom;
}
/* Orders Table */
.order_table {
width: 900px;
}
th.fix_width {
width: 900px;
}
hr#prod_break {
/* Gradient transparent - color - transparent */
border: 0;
height: 1px;
width: 600px;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
.tbl_repeat
{
position:relative;
-webkit-box-shadow:0 1px 10px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow:0 1px 10px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow:0 1px 10px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
.tbl_repeat:before, .tbl_repeat:after
{
position:absolute;
z-index:-1;
-webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);
-moz-box-shadow:0 0 20px rgba(0,0,0,0.8);
box-shadow:0 0 20px rgba(0,0,0,0.8);
top:50%;
bottom:0;
left:10px;
right:10px;
-moz-border-radius:400px / 100px;
border-radius:400px / 100px;
}
/* Product Paging */
.paging {
list-style: none;
width: 900px;
float: left;
/* background: #efefef; */
padding: 10px 10px;
color: white;
}
.paging li {
float: left;
margin-right: 10px;
font-size: 14px;
}
.paging a {
text-transform: none;
text-decoration: underline;
color: black;
padding: 0;
font-weight: normal;
color: white;
}
/* Pagination Navigation Buttons
http://www.flaticon.com/packs/metrize - - no class colour: #D9D9D9
*/
a.first {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/first.svg') top center no-repeat;
background-size: 32px;
}
a.firstno {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/firstno.svg') top center no-repeat;
background-size: 32px;
}
a.previous {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/previous.svg') top center no-repeat;
background-size: 32px;
}
a.previousno {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/previousno.svg') top center no-repeat;
background-size: 32px;
}
a.next {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/next.svg') top center no-repeat;
background-size: 32px;
}
a.nextno {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/nextno.svg') top center no-repeat;
background-size: 32px;
}
a.last {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/last.svg') top center no-repeat;
background-size: 32px;
}
a.lastno {
position: relative;
display: block;
width: 32px;
height: 32px;
background: url('../images/lastno.svg') top center no-repeat;
background-size: 32px;
}
a#top_of_page {
display: block;
position: relative;
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
background-color: #43a9d9;
top: -31px;
left: 45px;
color: white;
border-radius: 4px;
padding: 7px;
}
/* Proceed to Paypal */
#frm_pp {
display: none
}
.dn {
display: none;
}
/* Google reCAPTCHA */
.g-recaptcha {
display: inline-block;
position: relative;
width: 304px;
height: 78px;
}
/* Footer */
footer.main, #footer {
bottom: 0px;
width: 100%;
height: 182px;
position: fixed;
text-align: center;
margin-bottom: -20px;
}
footer.main div.footbord {
border-top-left-radius: -10px;
border-top-right-radius: -10px;
background-color: blue;
}
#uncopyright, #credits {
width: 100%;
margin: 5px 5px;
text-align: center;
display: inline-block;
position: static;
clear: both;
}
#uncopyright {
display: inline-block;
position: static;
margin-top: -20px;
clear: both;
}
div.social img {
width: 40px;
position: relative;
margin: 5px;
display: inline-block;
}
.social {
position: static;
height: 56px;
display: inline-block;
}
.social, .social a {
text-transform: uppercase;
text-decoration: none;
list-style: none;
padding: 0px 10px;
font-weight: bold;
color: black;
margin: 0;
}
/* -- Center Placeholder For Form Text and Keep Entry Field Left -- */
::-webkit-input {
text-align: left;
}
::-webkit-input-placeholder {
text-align: center;
}
::-moz-placeholder {
text-align: center;
}
/* -- Blank Spacing At Bottom Of Main Container -- */
div.nav_top {
height: 30px;
width: 100px;
}
div.nav_top_after {
height: 30px;
width: 100px;
}
div.cont_bot {
height: 230px;
width: 100px;
}
div.cat_space {
height: 20px;
}
/* Force Elements To Self Clear Its Children: http://css-tricks.com/snippets/css/clear-fix/ */
.clearfix:after {
visibility: hidden;
display: block;
content: "";
clear: both;
height: 0;
}
* html .group { zoom: 1; } /* IE6 */
*:first-child+html .group { zoom: 1; } /* IE7 */
I fixed it by messing around all evening with floats in CSSEdit. A great application!

My links shift to the left when clicked

I'm designing a website and having a problem with my links. When I click on them they shift to the left. Sometimes this prevents them from actually being clickable. I have not been able to find a single solution through googling and have no idea what part of my code is causing this. Any help would be appreciated.
Website
body {
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
color: #151515;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
background-color: #F9F9F9;
font-style: normal;
font-variant: normal;
font-weight: lighter;
font-size: small;
list-style-type: none;
text-align: center;
}
#header {
background-color: #171717;
float: left;
text-align: center;
height: 75px;
width: 100%;
}
#header1 {
padding-top: 21px;
background-color: #171717;
width: 20%;
float: left;
text-align: center;
}
#header2 {
background-color: #171717;
float: left;
text-align: center;
width: 20%;
padding-top: 33px;
font-size: 11px;
}
#header2 ul {
list-style-type: none;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
background-color: undefined;
font-size: small;
}
#header2 a {
width: 20%;
display: block;
float: left;
text-align: center;
font-size: 11px;
font-weight: bold;
text-decoration: none;
color: #CCCCCC;
}
#header2 a:hover , a:active, a:focus{
text-decoration: none;
color: #ffffff;
float: left;
}
#header3 {
float: left;
width: 20%;
text-align: center;
font-size: 11px;
padding-top: 23px;
font-weight: bold;
-webkit-box-shadow: 0px 0px;
box-shadow: 0px 0px;
}
#search {
width: 15%;
}
#search input[type="text"] {
background-repeat: no-repeat;
background-position: 10px 6px;
background-image: url(https://gray.secure-host.com/thefilterconnection/shopsite_sc/store/html/media/search-dark.png);
background-color: #909090;
border: 0 none;
font: bold 12px Arial,Helvetica,Sans-serif;
color: #CCCCCC;
padding-top: 6px;
padding-bottom: 6px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
padding-left: 35px;
}
#header4 {
width: 20%;
text-align: center;
float: left;
padding-top: 16px;
font-size: 11px;
font-weight: bold;
color: #CCCCCC;
}
#header5 {
width: 20%;
background-color: #171717;
text-align: center;
padding-top: 13px;
font-size: 11px;
font-weight: bold;
float: left;
color: #CCCCCC;
}
#productmenucontainer {
background-color: #171717;
width: 100%;
clear: both;
float: center;
height: 30px;
}
#productmenu {
width: 100%;
background-color: #171717;
padding-top: 3px;
text-align: center;
right: auto;
left: auto;
max-width: 100%;
}
#container1 {
float: left;
width: 100%;
background-color: #EBEBEB;
position: relative;
right: 75%;
}
#container2 {
float: left;
width: 100%;
background-color: #FFFFFF;
overflow: hidden;
position: relative;
}
#container3 {
min-width: 740px;
max-width: 1000px;
margin-left: auto;
margin-right: auto;
clear: left;
float: none;
display: inline-block;
-webkit-box-shadow: 1px 1px 5px 1px #DBDBDB;
box-shadow: 1px 1px 5px 1px #DBDBDB;
width: 100%;
}
#sidebar1 {
float: left;
width: 17%;
position: relative;
left: 75%;
padding-left: 4%;
padding-top: 2%;
text-align: left;
padding-bottom: 2%;
padding-right: 4%;
}
#sidebar1 ul {
list-style-type: none;
margin-left: -25px;
margin-top: 2px;
float: left;
width: 100%;
text-align: left;
}
#main {
float: left;
width: 64%;
position: relative;
left: 75%;
padding-left: 4%;
padding-top: 2%;
padding-bottom: 2%;
padding-right: 4%;
}
#footer {
background-color: #F9F9F9;
font-weight: lighter;
padding-top: 4px;
font-size: 11px;
text-align: center;
clear: left;
padding-bottom: 4px;
color: #6C6C6C;
min-width: 740px;
max-width: 1000px;
width: 100%;
margin-right: auto;
margin-left: auto;
position: relative;
display: inline-block;
}
#disclaimer {
text-align: center;
float: left;
width: 23%;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 1%;
padding-right: 1%;
}
#creditcards {
width: 35%;
float: left;
padding-top: 5px;
}
#share {
width: 20%;
text-align: center;
float: left;
padding-top: 5px;
}
#follow {
float: left;
padding-top: 5px;
width: 20%;
}
#copyright {
clear: left;
float: left;
text-align: center;
padding-top: 5px;
width: 100%;
background-color: #626262;
color: #F3F3F3;
font-size: x-small;
font-weight: bold;
font-style: italic;
}
a:link {
color: #575757;
text-decoration: none;
font-weight: bold;
font-size: small;
}
a:visited {
color: #6C6C6C;
}
a:hover, a:active, a:focus {
text-decoration: none;
color: #7F7F7F;
}
.menu {
background-color: #B1CCE0;
text-align: center;
width: 100%;
min-width: 740px;
max-width: 1000px;
left: auto;
right: auto;
float: left;
margin-left: auto;
margin-right: auto;
}
.menu > span {
display:inline-block;
margin:0 auto;
}
#nav {
display: inline;
text-align: left;
position: relative;
list-style-type: none;
z-index: 1000;
}
#nav > li {
float: left;
padding: 0;
position: relative;
color: #6C6C6C;
}
#nav > li > a {
border: 1px solid transparent;
color: #CCCCCC;
display: block;
font-size: small;
padding: 3px 10px;
position: relative;
text-decoration: none;
font-weight: bolder;
-webkit-box-shadow: 0px 0;
box-shadow: 0px 0;
text-shadow: 0px 0;
}
#nav > li > a:hover {
background-color: #e4ecf4;
border-color: #999;
}
#nav > li.selected > a {
background-color: #171717;
border-color: #999999 #999999 #FFFFFF;
z-index: 2;
}
#nav li div {
position:relative;
}
#nav li div div {
background-color: #FFFFFF;
border: 1px solid #999999;
padding: 12px 0;
display: none;
margin: 0;
position: absolute;
top: -1px;
z-index: 1;
width: 190px;
}
#nav li div div.wrp2 {
width: 380px;
background-color: #171717;
}
#nav .sep {
left:190px;
border-left:1px solid #E3E3E3;
bottom:0;
height:auto;
margin:15px 0;
position:absolute;
top:0;
width:1px;
}
#nav li div ul {
padding-left: 10px;
padding-right: 10px;
position: relative;
width: 170px;
float: left;
list-style-type: none;
background-color: #171717;
}
#nav li div ul li {
margin:0;
padding:0;
}
#nav li div ul li h3 {
border-bottom: 1px solid #E3E3E3;
color: #4F87C5;
font-weight: bold;
margin: 0 5px 4px;
padding-bottom: 3px;
padding-top: 3px;
font-size: small;
}
#nav li div ul li h3 a {
color: #4F87C5;
font-weight: bold;
font-size: small;
}
#nav li div ul li h3 a:hover {
color: #89B3E1;
font-weight: bold;
font-size: small;
}
#nav li ul ul {
padding-top: 0;
padding-right: 0;
padding-left: 0;
padding-bottom: 0;
bottom: 8px;
}
#nav li ul ul li {
margin-bottom: 1px;
padding-top: 3px;
padding-right: 5px;
padding-left: 5px;
padding-bottom: 3px;
}
#nav li ul ul li a {
color: #CCCCCC;
display: block;
text-decoration: none;
font-size: 10px;
font-weight: bold;
}
#nav li ul ul li a:hover{
background-color: #171717;
color: #ffffff;
}
#header2 a:hover , a:active, a:focus{
text-decoration: none;
color: #ffffff;
**float: left;**
}
This is the part I'm most suspicious of. What happens without the float: left - or, if you apply it to those links in their original CSS rule, not the :active one?
You have an issue in your css file demopage.css on line 61, you need to remove a:active and a:focus from that declaration. Basically on every click on all a tags on your page they get a float: left value. So if you remove them from it everything will work perfectly :)
I have tested it on your site and it works :)
So from this
#header2 a:hover, a:active, a:focus {
text-decoration: none;
color: #ffffff;
float: left;
}
to this
#header2 a:hover {
text-decoration: none;
color: #ffffff;
float: left;
}

Hide <li> on touch/scroll outside

On the mobile devices, I need to hide li when scroll or pressing any area of screen. This is on the fixed header menu and how can I achieve this ? Thank you for your help.
HTML:
<ul class="profilenav">
<li id="settingslink">
<div id="settingslist">
<ul class="sub">
<li>AAAAA</li>
<li>AAAAA</li>
<li>AAAAA</li>
</ul>
</div>
</li>
<li>BBBBB</li>
<li>CCCCC</li>
</ul>
</header>
</div>
CSS:
body #Head h1 {
border: 0 none;
display: inline-block;
font-weight: bold;
margin: 0;
padding: 0 10px 0 0;
}
ul { list-style: none; }
img { border: 0; }
p { font-size: 1.3em; line-height: 1.25em; color: #666; margin-bottom: 15px; }
#wrap { display: block; margin: 0 auto; padding: 0px 40px; }
#settingslink { position: relative; }
#settingslink:hover { background: #fff !important; }
#settingslink:hover a { color: #3f6998; }
.HeaderWrap {
width: 100%;
background: #F5F5F5;
border:1px solid #D8D8D8;
border-width:1px 0;
}
header {
width: 98%;
margin-left: auto;
margin-right: auto;
display: block;
position: relative;
height: 35px;
border: 0;
}
.logo { float: left; color: #fff; display: block; margin-left: 10px; font-size: 24px; letter-spacing: normal; line-height: 35px; }
.profilenav { position: absolute; right: 0; }
.profilenav li { display: block; font-size: 1.2em; float: left; }
.profilenav a { display: block; line-height: 25px; font-size: 18px; color: #333333; text-decoration: none; padding: 0 10px; z-index: 10; }
.profilenav a:hover { color: #b6cadd; }
.profilenav li:hover #settingslist { display: block; position: absolute; }
#settingslist { background: #fff; display: none; position: absolute; padding-top: 7px; -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0 1px 1px rgba(0,0,0,0.5); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); z-index: 100; }
#settingslist .sub { background: #fff; }
#settingslist .sub li { font-size: 10px; font-weight: ; background: #fff; text-align: left; }
#settingslist .sub li a { background: #fff; display: block; line-height: 25px; padding: 3px 6px; color: #596774; width: 120px; }
#settingslist .sub li a:hover { background: #537db9; color: #fff; }
#avatar { float: right; display: block; width: 240px; }
#avatar img { padding: 3px; border: 1px solid #cbcbcb; }
#body { display: block; background: #fff; min-height: 200px; margin-top: 50px; padding: 11px 20px; padding-bottom: 30px; }
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
.clearfix { display: inline-block; }
html[xmlns] .clearfix { display: block; }
* html .clearfix { height: 1%; }

Resources