This question already has answers here:
'transform3d' not working with position: fixed children
(10 answers)
Closed 3 years ago.
I have an absolutely positioned Bootstrap 3 dropdown mega menu that is offsetting it's position from a static parent div. I want it to position itself to a relative parent that's further up the DOM.
I've tried using !important rules to set every parent (but the correct one) to position: static - but this won't work.
This doesn't have the correct visuals, but this CodePen demonstrates the issue:
https://codepen.io/anon/pen/mNEyVR
.site-header {
box-sizing: border-box;
color: rgb(51, 51, 51);
display: block;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
height: 150.15px;
line-height: 22.85px;
position: relative;
-moz-osx-font-smoothing: grayscale;
}
.site-header__main {
border-bottom-color: rgb(236, 236, 236);
border-bottom-style: solid;
border-bottom-width: 1px;
box-sizing: border-box;
color: rgb(51, 51, 51);
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
height: 85px;
line-height: 22.85px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
position: relative;
-moz-osx-font-smoothing: grayscale;
}
.site-header__main-inner {
background-attachment: scroll;
background-clip: border-box;
background-color: rgb(255, 255, 255);
background-image: none;
background-origin: padding-box;
background-position: 0% 0%;
background-position-x: 0%;
background-position-y: 0%;
background-repeat: repeat;
background-size: auto;
box-sizing: border-box;
color: rgb(51, 51, 51);
display: flex;
flex-direction: row;
flex-wrap: nowrap;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
height: 68px;
line-height: 22.85px;
margin-bottom: 16px;
margin-left: 0px;
margin-right: 0px;
margin-top: 16px;
padding-bottom: 0px;
padding-left: 40px;
padding-right: 40px;
padding-top: 0px;
position: relative;
z-index: 999;
-moz-box-direction: normal;
-moz-box-orient: horizontal;
-moz-osx-font-smoothing: grayscale;
}
.site-nav {
background-attachment: scroll;
background-clip: border-box;
background-color: rgba(0, 0, 0, 0);
background-image: none;
background-origin: padding-box;
background-position: 0% 0%;
background-position-x: 0%;
background-position-y: 0%;
background-repeat: repeat;
background-size: auto;
border-top-color: rgb(51, 51, 51);
border-top-style: none;
border-top-width: 0px;
box-sizing: border-box;
color: rgb(51, 51, 51);
flex-basis: 0px;
flex-grow: 1;
flex-shrink: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
height: 68px;
left: 0px;
line-height: 22.85px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
overflow: visible;
overflow-x: visible;
overflow-y: visible;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
position: static;
top: 0px;
transform: matrix(1, 0, 0, 1, 0, 0);
transition-delay: 0s, 0s, 0s;
transition-duration: 0.36s, 0.36s, 0.36s;
transition-property: transform, visibility, transform;
transition-timing-function: ease, ease, ease;
visibility: visible;
width: 1015px;
z-index: auto;
-moz-box-flex: 1;
-moz-osx-font-smoothing: grayscale;
}
nav {
box-sizing: border-box;
color: rgb(51, 51, 51);
display: block;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 22.85px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
visibility: visible;
-moz-osx-font-smoothing: grayscale;
}
ul {
box-sizing: border-box;
color: rgb(51, 51, 51);
display: flex;
float: left;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
justify-content: flex-end;
line-height: 22.85px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
visibility: visible;
width: 1015px;
-moz-box-pack: end;
-moz-osx-font-smoothing: grayscale;
}
li.open {
box-sizing: border-box;
color: rgb(51, 51, 51);
display: block;
float: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 22.85px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
position: static;
visibility: visible;
-moz-osx-font-smoothing: grayscale;
}
.dropdown-menu {
background-attachment: scroll;
background-clip: border-box;
background-color: rgb(236, 236, 236);
background-image: none;
background-origin: padding-box;
background-position: 0% 0%;
background-position-x: 0%;
background-position-y: 0%;
background-repeat: repeat;
background-size: auto;
border-bottom-color: rgb(214, 214, 214);
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-image-outset: 0;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgb(51, 51, 51);
border-left-style: none;
border-left-width: 0px;
border-right-color: rgb(51, 51, 51);
border-right-style: none;
border-right-width: 0px;
border-top-color: rgb(51, 51, 51);
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-top-style: none;
border-top-width: 0px;
box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;
box-sizing: border-box;
color: rgb(51, 51, 51);
display: none;
float: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
left: 0px;
line-height: 22.85px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
min-width: 160px;
padding-bottom: 32px;
padding-left: 0px;
padding-right: 0px;
padding-top: 16px;
position: absolute;
text-align: left;
top: 100%;
visibility: visible;
width: 100%;
z-index: 1000;
-moz-osx-font-smoothing: grayscale;
}
li.open .dropdown-menu {
background-attachment: scroll;
background-clip: border-box;
background-color: rgb(236, 236, 236);
background-image: none;
background-origin: padding-box;
background-position: 0% 0%;
background-position-x: 0%;
background-position-y: 0%;
background-repeat: repeat;
background-size: auto;
border-bottom-color: rgb(214, 214, 214);
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-image-outset: 0;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgb(51, 51, 51);
border-left-style: none;
border-left-width: 0px;
border-right-color: rgb(51, 51, 51);
border-right-style: none;
border-right-width: 0px;
border-top-color: rgb(51, 51, 51);
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-top-style: none;
border-top-width: 0px;
box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;
box-sizing: border-box;
color: rgb(51, 51, 51);
display: block;
float: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
left: 0px;
line-height: 22.85px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
min-width: 160px;
padding-bottom: 32px;
padding-left: 0px;
padding-right: 0px;
padding-top: 16px;
position: absolute;
text-align: left;
top: 68px;
visibility: visible;
width: 1015px;
z-index: 1000;
-moz-osx-font-smoothing: grayscale;
}
<header class="site-header">
<div class="site-header__main">
<div class="site-header__main-inner">
<div class="site-nav">
<nav>
<ul>
<li class="open">
Link 1
<div class="dropdown-menu">
<p>content 1</p>
</div>
</li>
<li>
Link 2
<div class="dropdown-menu">
<p>content 2</p>
</div>
</li>
<li>
Link 3
<div class="dropdown-menu">
<p>content 3</p>
</div>
</li>
</ul>
</nav>
</div>
</div>
</div>
</header>
If you Inspect the first .dropdown-menu in Firefox, you'll see in the Layout tab that the menu is positioning itself in relation to a static parent.
It should be positioning in relation to a further-up parent that actually has its position set to relative.
I tried reducing my code the make it easier to parse and I solved my own problem.
The div .site-nav was incorrectly acting a the relative parent to my absolute div.
For some reason, this was caused by this CSS: transform: matrix(1, 0, 0, 1, 0, 0);
I've never used the matrix code before so I don't know what this does. It wasn't even in my code. My code was transform: translateY(0) and apparently my gulp file was adding the goofy matrix content. I changed the transform to transform: none and the problem was fixed!
I'm sort of a noob to developing websites, but hope to learn more. The problem I'm having is that my main page content goes under my footer if the page holds more and more content. ( https://i.imgur.com/LeqVBwl.png )
Either I'm doing something wrong, or I'm just missing something but, here's how I did it:
How could I fix this? Do I have to add/remove something?
The "position: absolute" is so it says at the bottom
CSS:
body {
margin: 0 0 65px;
background: #000000 url(../images/bg.png);
padding-bottom: 65px;
}
#menu {
height: 50px;
padding-left: auto;
padding-right: auto;
background: #ccc no-repeat left top;
font-family: Arial, Helvetica, sans-serif;
}
#menu ul {
margin: 0;
padding: 0;
list-style: none;
line-height: normal;
}
#menu li {
float: left;
}
#menu a {
display: block;
float: left;
padding: 18px;
margin-right: 1px;
background: lightgray no-repeat;
text-decoration: none;
font-size: 10px;
color: #FFFFFF;
}
#menu a:hover {
color: #FFFFFF;
background: darkgray;
}
.main {
width: 1300px;
margin-right: auto;
margin-left: auto;
margin-top: 20px;
border: 1px black solid;
}
.content {
font-family: "Trebuchet MS", Helvetica, sans-serif;
margin-top: 40px;
margin-right: auto;
border: 1px solid #ccc;
width: 800px;
float: left;
background: white;
border-radius: 2px;
}
.content h2 {
font-size: 18px;
font-weight: bold;
border-bottom: 1px solid #ccc;
text-align: center;
}
.sidebar {
font-family: "Trebuchet MS", Helvetica, sans-serif;
margin-top: 40px;
margin-left: 30px;
margin-right: auto;
border: 1px solid #696969;
width: 300px;
float: right;
background: #EDEDED;
border-radius: 2px;
}
.sidebar h2 {
font-size: 15px;
font-weight: bold;
border-bottom: 2px solid #ccc;
text-align: center;
}
#footer {
font-family: "Trebuchet MS", Helvetica, sans-serif;
background: #ccc no-repeat left;
border-top: 3px solid;
left: 0;
bottom: 0;
height: 65px;
width: 100%;
}
#footer .footer-content {
font-weight: bold;
color: #262626;
font-size: 14;
}
#footer .footer-content a {
color: #545454;
text-decoration: none;
font-size: 14px;
}
#footer .footer-content a:hover {
color: #6E6E6E;
text-decoration: none;
font-size: 14;
}
HTML:
<div id="footer">
<div class="footer-content">
<center>
Home | Forums | Contact | Signup |Login
</center>
</div>
</div>
Fixed
I seemed to have fixed my problem. I just added:
<div style="clear: both;"> </div>
It's because you're footer has position: absolute; applied, this means it jumps out of the normal flow of the page. To fix it, add a padding equal to the height of the footer to the bottom of the page.
body {
padding-bottom: 65px;
}
How to change font size for my SMF forum theme? I see percentages which change only some parts of the text, can't find where to change post font, thread font etc...
Please just point me in the right direction, also what does xx%/yy% mean in regards to the font?
/* SMFSimple.com Theme Style */
body
{
background: url(../images/theme/bg.png) #f8f8f8;
font: 78%/130% 'Oxygen',sans-serif;
padding: 0px;
}
a:link, a:visited {color: #4D4D4D;}
a.new_win:link, a.new_win:visited {color: #4D4D4D;}
input, button, select, textarea
{
font: 95%/115% 'Oxygen',sans-serif;
color: #000;
background: #fff;
border: 1px solid #7f9db9;
}
textarea
{
font: 100%/130% 'Oxygen',sans-serif;
}
.smalltext, tr.smalltext th
{
font-size: 0.85em;
font-family: 'Oxygen',sans-serif;
}
.middletext
{
font-size: 0.9em;
line-height: 1em;
font-family: 'Oxygen',sans-serif;
}
.normaltext
{
font-size: 1em;
line-height: 1.2em;
}
.largetext
{
font-size: 1.4em;
}
code.bbc_code
{
display: block;
font-family: 'Oxygen',sans-serif;
font-size: x-small;
background: #eef;
border-top: 2px solid #999;
border-bottom: 2px solid #999;
line-height: 1.5em;
padding: 3px 1em;
overflow: auto;
white-space: nowrap;
/* Show a scrollbar after about 24 lines. */
max-height: 24em;
}
.bbc_tt
{
font-family: 'Oxygen',sans-serif;
}
#font-face {
font-family: 'Oxygen';
font-style: normal;
font-weight: 400;
src: local('Oxygen'), local('OpenSans'), url(../fonttheme.woff) format('woff');
}
#full_header
{
margin: 0 auto;
min-width: 764px;
max-width: 2300px;
}
#bar_social
{
background: rgba(255, 255, 255, 0.7);
height: 50px;
border: 1px solid #e8e8e8;
}
.ss_content_header
{
clear: both;
overflow: hidden;
width: 100%;
padding: 20px 0px;
padding: 20px 0px;
}
.ss_logo
{
width: 48%;
float: left;
margin-top: 10px;
padding-left: 20px;
}
.ss_user_area
{
width: 48%;
float: left;
margin-top: 15px;
}
.table_user
{
border-radius: 5px;
background: rgba(00, 00, 00, 0.7);
padding: 0px 10px;
font-size: 12px;
border: 1px solid #333;
text-shadow: 0px 1px 1px #666;
}
.user
{
color: #f4f4f4;
}
.user a
{
color: #F9BC06;
}
.ss_avatar_pad
{
padding-right: 15px;
}
This line:
font: 78%/130% 'Oxygen',sans-serif;
breaks down to:
font-size: 78%;
line-height: 130%;
font-family: 'Oxygen', sans-serif;
If no font size is given explicitly, the browser's default value is used, which is actually 16px.
I'm trying to position a searchbox and submit button so that they are line up. I've used a CSS reset to have all browsers starting from the same level. For whatever reason, I can't get them to line up on the IE, Chrome and Firefox. I can get it working on 1/3 but not 3/3. With the current code, the search button is aligned in FF, 1px lower in IE, and 3-5px lower in Chrome. Any help is much appreciate as I am at my wits end.
Here's the code.
HTML snippet:
<span class="search">
<form id="searchbox" action="/search" method="get">
<input name="query" id="search" type="text" placeholder="I'm looking for..."/>
<input id="submit" class="mglass" type="submit" value=""/>
</form>
</span>
CSS snippet:
* {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
#search{
position: relative;
bottom: 1px;
height: 27px;
width: 200px;
font-size: 14px;
font-family: 'calibri', Tahoma, Geneva, sans-serif;
border: none;
background-color: #eee;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
padding-left: 10px;
}
#searchbox{
position: relative;
right: 27px;
top: 5px;
float: right;
}
input[type="submit"]::-moz-focus-inner {
border: 0;
padding: 0;
}
input[type="text"]::-moz-focus-inner {
border: 0;
padding: 0;
}
.mglass{
background: url(../images/search_glass01.png) no-repeat center;
height: 29px;
width: 33px;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
position: relative;
right: 7px;
bottom: 0px;
}
.mglass:hover{
background: url(../images/search_glass02.png) no-repeat center;
}
I had to hack up your CSS a bit and simplified some of the selectors to get my head around it, but, give this a try:
http://jsfiddle.net/R56mu/
body {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
#searchbox{
float: right;
overflow:hidden;
}
#search{
width: 200px;
height:32px;
float:left;
padding: 0 0 0 10px;
background-color: #eee;
font-size: 14px;
font-family: 'calibri', Tahoma, Geneva, sans-serif;
border: none;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
}
#submit{
width: 33px;
height:34px;
float:left;
background: url(../images/search_glass01.png) no-repeat center;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
}
#submit:hover{
background: url(../images/search_glass02.png) no-repeat center;
}
input[type="submit"]::-moz-focus-inner {
border: 0;
padding: 0;
}
input[type="text"]::-moz-focus-inner {
border: 0;
padding: 0;
}
I just tested my new site with my android phone and I am not able to scroll anywhere on the page. On Firefox, opera, ie, and chrome desktop browsers I get vertical scroll when needed. In my html, body css rule I've got overflow-y to scroll; Width should not be scrolled. I'm probably missing something simple here but I've never come across this in any other sites I've done.
Here's my css for the site:
#charset "utf-8";
/* CSS Document */
#body{
min-width: 900px;
width: 75%;
background-size: cover;
background-image: url(../graphics/back2.jpg);
position: relative;
margin: 40px auto;
padding: 10px;
border-style: groove;
border-width: 5px;
border-color: #000;
background-repeat: repeat-y;
}
a:link, a:visited, a:active{
text-decoration: none;
color: inherit;
}
a:hover{
color: #FFF;
text-decoration: underline;
}
html, body{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow-y: scroll;
background-image: url(../graphics/craig-smith-background.jpg);
line-height: 25px;
}
h1{
font-size: 36px;
font-family: "Times New Roman", Times, serif;
color: #000;
margin: 10px;
}
h2{
font-size: 30px;
font-family:"Times New Roman", Times, serif;
margin-left: 30px;
color: #333;
font-weight: 700;
margin: 20px;
}
h3{
font-size: 24px;
margin: 10px;
}
p{
font-size: 20px;
font-family: "Times New Roman", Times, serif;
color: #FFF;
text-indent: 1.5em;
margin-left: 1.5em;
}
#quote{
margin-left: 30px;
font-style: italic;
font-family: lucida;
font-size: 18px;
border-style: inset;
border-color: #333;
border-width: 2px;
height: 80px;
}
#header{
width: auto;
margin: 0 auto;
position: relative;
text-align: center;
}
#nav{
position: absolute;
z-index: 1;
left: 25%;
top: 150px;
}
.picture{
display: inline-block;
position: relative;
margin: 0 auto;
border-style: groove;
border-width: 5px;
border-color: #999;
}
.clear-left{
clear: left;
position: relative;
}
.clear-right{
clear: right;
position: relative;
}
.clear-all{
clear: both;
position: relative;
}
#left-col{
width: 25%;
min-width: 300px;
position: relative;
float: left;
text-wrap: normal;
overflow: hidden;
margin-bottom: 10px;
margin-top: 10px;
text-align: right;
}
#right-col{
min-height: 500px;
min-width: 500px;
width: 65%;
text-align: left;
float: right;
border-style: groove;
border-width: 5px;
border-color: #CCC;
margin-bottom: 10px;
margin-top: 10px;
text-wrap: normal;
text-indent: 10px;
}
#footer{
width: 85%;
height: 40px;
background-color: #999;
text-align: center;
margin: 10px auto;
padding: 0px;
padding-bottom: 10px;
border-style: groove;
border-width: 2px;
border-color: #999;
}
#project-description h1{
text-align: center;
font-size: 36px;
}
.project-description h2{
color: #333;
font-weight: bold;
}
.project-description{
border-style: inset;
border-width: 3px;
border-color: #333;
margin: 10px;
padding: 5px;
}
.project-description p{
margin-left: 70px;
text-indent: 0;
}
table{
border-spacing: 0;
border-collapse: collapse;
}
td, th, tr{
padding: 0;
line-height: 20px;
}
And here's a link the live site.
You don't need to give the body and html tags the overflow-y: scroll; style. That is resulting in a double scrollbar which is failing in mobile browsers. You don't even need to specify that as it is default behavior. You may want to set overflow-y: scroll; and overflow-x: hidden; on the body tag only.