Elements overlapping on responsive design - css

The design I'm working on (apart from the desktop version) has been thinking for a 480px x 720px resolution, but it suppose to show ok on smaller devices. I'm having a lot of problems with the elements on it, they are all overlapping.
This is how it should look like
And this is how it looks on a smaller resolution
My main concern right now is with the overlapping elements, I know I may need to adjust some other things using media queries, but I don't want to continue until I fix this:
correctly position the menu (as it moves and finally disappear).
Show the full masked image.
Prevent buttons (images) from overlapping.
Prevent text from leaving div.
As I believe that I have a very confusing mix/absence of position and display elements on my css.
Relevant code:
#media only screen and (max-width: 500px) {
/*for the menu*/
.site-header {
display: block !important;
}
.sidebar-toggle { //the menu bar-icon properly
right: 390px !important; // I needed to do this because it was originally on the right side (im working on the Magnus theme in wordpress)
display: table;
position: absolute;
float:left;
}
/*for showing the masked image*/
.content-area { //the div that contains the "A" masking the image
overflow: hidden; //without this scroll appears
}
h1.masking-a {
display: block;
position: relative;
}
/*for the text and image buttons*/
.square-footer { //the container div
position: fixed;
}
.square-footer-text {
position: fixed;
}
.square-footer-text p {
position: relative;
text-align: center !important;
}
.square-footer img {
position: fixed;
}
}

Related

Mobile menu button jumping around

I am building a website for my church,
https://new.churchindenver.org/
and I have a mobile "Menu" button that opens the mobile menu, and a "Close" button that closes it.
Both have the following CSS:
display: inline;
position: absolute;
top:10px;
right: 10px;
I want the menu button to be in absolute position
top:10px;
right: 10px;
When the screen width is 601-895px it works fine. When the screen width is <=600px, the css is being ignored and the "Menu" button jumps down about 50px. (and the logo jumps down too, incidentally, though not as far) Does anyone have any idea why?
Thanks!
Whether ! important or not, and no matter what I put there, the menu button (and the logo) are in absolute position, but apparently not to their parent element.
UPDATE:
Based on Elraphty's suggestion, I made the following hack, which seems to fix it. I'm still not sure what's going on, but at least it looks right. I put:
#media (max-width: 600px) {
#menu {
top: -41px ! important;
}
#logo {
top: -10px ! important;
}
}
and now the menu button and logo are in their proper position at top 10px.
The error is caused by
top:10px;
right: 10px;
Since they both have absolute positions, the solution write a media query than changes the top and right values when the screen is lesser than 600px e.g
#media screen and (max-width: 600px) {
. class {
top: 5px ! important;
right: 5px ! important;
}
}
You can also do this
.nav {
position: relative
}
.navItems {
display: inline;
position: absolute;
top:10px;
right: 10px;
}
So the items are positioned absolute in the nav element not the body element
Or use flex
.nav {
height: 100px;
display: flex;
flex-direction: row;
justify-content: center;
}

why isn't the footer sticking to the bottom of the page?

I have tried 100 different ways to get the footer to stick to the bottom of the page. On all my other pages, it operates fine however on one page, the footer floats to the middle. This is the code I am trying to work but clearly something is off.
#media screen and (min-width : 768px) {
.page-id-94 html, body {
display: none;
}
.site, .site-content {
height: 100%;
}
#boldgrid-sticky-wrap {
min-height: 100%;
height: auto !important;
height: 100%;
}
}
I need this to execute in mobile/smaller screen versions only therefore I used the media query.
I am learning CSS as I go so all this is very new for me. All help is appreciated
Not sure what you're trying to do here, but this is how I usually do my footers:
.footer {
position: absolute;
bottom: 0;
width:100%;
height:20%; //you can hard code a px value for this
padding: 5px; //you may wish to change this as well
}

Hide a fixed position DIV using #media display:none

The div in question is:
.fixed {
position: fixed;
bottom: 0;
left: 0;
width: 200px;
background-color: white;
}
What I want is:
#media screen and (max-width: 720px){
.fixed { display: none; }
}
However apparently that's not how fixed containers work?
So how can I hide a "sticky" container when the screen gets resized to something too small to display both the container and the main content and thus making the container overlap the content?
Your css code seems to be working fine, perhaps there is a rule that has more importance/weight than the one in your media query, add !importat and see if it works:
#media screen and (max-width: 720px){
.fixed { display: none !important; }
}

Responsive design

So im self teaching myself responsive design & am trying to put together a right hand divider that remains the same size, while the left hand resizes down to 240 before pushing the right div down..
The reasoning - so that changing window sizes keeps the correct format and the design is suitable for various mobile devices (down to 240px).
Now with the way it is setup I cannot seem to get the right div to push down below the left once the screen width is reduced to less than 480px.
CSS
.menu {
position: relative;
float: left;
min-width: 240px;
margin-left: -240px;
}
.content {
position: relative;
float: left;
min-width: 240px;
}
#media screen {
.content {
width: calc(100% - 240px);
margin-right: 240px;
}
.menu {
}
}
What I can't figure out to do is to force the div (MENU) after the left div (CONTENT) for devices with a width of 480px or less? The reason for designing this way is so that the left content is scalable for all screen sizes (thus avoiding breakpoints for specific devices), but at the point where 480px is reached i want the elements to be displayed one after the other..
JS FIDDLE
After some lucky research, I have found that the following appears to work, but am not sure if this a reasonable or 'dirty' fix;
#media (min-width: 1px) and (max-width: 479px) {
.menu {
margin-left: 0px;
}
}
So a min-width and max-width is needed for the exception, in which the margin-left of <div class="menu"></div> is updated to 0px.
So below devices with a screen width of 480px it will shift the right side menu div down below the left side navigation div...
Take a look at this design.
What i've done is make it mobile first and percentage widths when your screen width is smaller than 480px the menu's take 100% of the space.
.content {
background:red;
position: relative;
width: 100%;
height: 200px;
}
.menu {
background:green;
position: relative;
width: 100%;
height: 200px;
}
This type of design is called mobile first and your should read about it on the web. It makes the styles load first on the mobile phone then progressively upgrade on wider screens.

Mobile Site Logo Alignment

I am looking to target my Jobspark logo while viewed on a mobile device. Currently it scrolls down the page and I would like to disable that and place it at top of the page and to the right hand side of the "Menu". This way I could delete the + symbol and it would fit nicely. Below is some code I tried to use to accomplish this. www.jobspark.ca
#media only screen and (max-width: 640px) {
#header #logo h1.site-title {
text-align: left !important;
float: right;
position: absolute;
top: 0;
right: 0;
}
}
Thanks for the help.
******************Update***********************
- Logo hides behind the top navigation while in mobile
- Would like navigation color to be black while in mobile
- Menu text then needs to be white
Here is an mock up of what I would like to accomplish
try this in site.css
#header #logo h1.site-title
{
text-align: left !important;
top: 0;
right: 0;
}
Change max-width to 38% for .primary-nav .nav in site.css
max-width: 38%;
Hope this solves your problem.

Resources