Fixed popup is cut off on mobile - html

I'm creating a website that opens a popup when you click on a certain element. My popup is a with the following styling (simplified from what I actually have, but this shows the problem):
.popup {
position: fixed;
width: 75vw;
height: 85vh;
top: 10%;
left: 50%;
transform: translateX(-50%);
background-color: gray;
overflow-y: scroll;
}
Now, it works perfectly on desktop: I get a scrollable popup that's 85% of the viewport, positioned correctly. Looks like this:
However, when I open the website on mobile, the popup is cut off at the bottom. Looks like this:
It should have some empty space at the bottom, just like on desktop.
I tried adding bottom margins and paddings, but nothing helps. I don't understand why this is happening. Also it's hard to debug because if I open it in mobile mode on desktop browser, everything looks correct. And when I created a CodePen with my code and opened it on mobile, it also showed fine. Please help.

I don't think your issue is with css at all and more about that bar at the bottom of the phone. I know you mentioned that you tried margin and padding and that wasn't working, but did you happen to do them on the paragraph element itself?
Underneath .popup, you can put .popup p {margin-bottom: 50px;}. This should solve your issue. You will have to play around with the distance from the bottom of the div to find what works for you.
.popup {
position: fixed;
width: 75vw;
height: 85vh;
top: 10%;
left: 50%;
transform: translateX(-50%);
background-color: gray;
overflow-y: scroll;
}
.popup p {
margin-bottom: 50px;
}
or you could simply add a media query
#media only screen and (max-width: 800px){
.popup p {
margin-bottom: 50px;
}

Related

Why is doesn't my content fill the full width in devtools responsive size

When visiting www.felkru.com and opening it in chrome devtools after resizing the window in responsive mode a bar appears on the right side of my content.The error also occures when zooming out on iOS. In Firefox, after following the same steps, no bar appears. How can I fix this?
The problem is with the picture. width: 100vw and padding section .about
solution:
section {
overflow: hidden;
}
or
#portrait {
position: relative;
left: 0;
bottom: -0.3em;
max-width: 100%;
}

CSS issue with Responsive HOVER DIV

I'm having a problem with the mobile version of a responsive website I'm building.
See that green "info" DIV that appears at the top left corner of the full-screen version of the site?
I need it to move down and live at the bottom of the screen - right above the footer DIV that has all the links - on the mobile version of the site.
Here's the full-screen version:
Here's the Mobile version:
Here's my CSS for the regular full-screen layout:
#productHoverDIV {
z-index: 20;
position: absolute;
top: 10px;
left: 10px;
width: 300px;
padding: 8px;
}
And here's the mobile rule:
#media screen and (max-width: 414px) {
#productHoverDIV {
z-index: 20;
position: absolute;
bottom: 40px; // that's the height of the FOOTER DIV below it
width: 100%;
padding-top: 0px;
padding-bottom: 0px;
}
}
The issue is that even though I'm telling the productHoverDIV to be 40px from the bottom on the mobile layout, it still keeps it's top:10px value from the regular CSS rule, and ends up covering almost the entire screen.
So I need to somehow cancel-out the top rule - or override it with a different value, except
I have no idea know what value to put from the top cause every mobile device has a different height.
How do I resolve this?
You should change it back to its default value, which is auto.
Removed the duplicated z-index and position values.
#media screen and (max-width: 414px) {
#productHoverDIV {
top: auto;
bottom: 40px;
width: 100%;
padding-top: 0px;
padding-bottom: 0px;
}
}

How to stop fixed page background from jumping on mobile

I have a full page height and width background image to a page that is designed to cover the who back of the viewport that also adapts to the size of the viewport. This work brilliantly on desktop - however on mobile (both iPhone and Android) when the address bar and navigation bars are hidden (default browser behavior) as you scroll down the background image jumps (as seen below):
https://ibb.co/7jWLqWh
The code I'm using for this is:
HTML:
<div id="bg">
<img src="../../assets/landing-page/bg.png" alt="">
</div>
CSS:
#bg {
position: fixed;
top: -32%;
left: -90%;
width: 200%;
height: 200%;
background-color: #FFFFFF;
}
#bg img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
opacity: 0.75;
}
As % values are being used, when there is suddenly more space because a browser bar has disappeared, the size suddenly jumps.
To get round this problem the suppliers decided to fix the vh height unit. While this can cause other problems, like full height 100vh divs having the bottom cut off when a website is entered, it was designed to help mitigate the sort of scrolling-jump problem seen here.
Suggestion is that you try defining the heights in vh units rather than %s to see if that fixes things.

Can't remove right margin and it grows as div width shrinks

This seems to be a pretty standard situation but the HTML/CSS is behaving oddly. I'm in the process of building a profile page for a game and am also looking at mobile responsiveness. I can't seem to get the right-margin to go away. It's not a problem in portrait mode (using a Chrome mobile emulator extension) but in landscape, the div + margin is too wide and a scrollbar appears.
HTML:
<div class="userProfile" style="display:none">
<div class="profileTop">
<div class="profilePicture">
<img src="somepicture.png"></img>
</div>
<div class="profileName"></div>
</div>
</div>
CSS:
.profileTop {
position: relative;
top: 10%;
left: 15%;
width: 70%;
height: 12%;
margin: 0;
}
.profilePicture {
display: inline-block;
width: 12vw;
}
.profilePicture img {
width: 100%;
height: auto;
vertical-align: top;
}
.profileName {
display: inline-block;
position: relative;
font-family:Stencil;
font-size: 1.3em ;
font-weight: lighter;
color: white;
left: 20%;
top: 35%;
}
What's odd is that if I decrease the width of the "profileTop" class, the right margin grows so that the whole thing is the same width. Any help?
EDIT: I can get a workable solution by reducing the width of "userProfile" but it's still bothering me that this won't work as originally intended.
EDITx2: The margin also exists on the "userProfile" div. I suppose the "profileTop" div is following its parent somehow but even if I add margin-right: 0 attributes to both divs, the margin is still there. The parent of "userProfile" is the body.
Error in HTML code, you don't need a closing tag for image.
Secondly, you can use media queries to achieve that. Media queries even have an option for landscape and it's really easy to use. Good luck
#media (min-width: 700px) and (orientation: landscape) { ... }
P.S. Use codepen or jsFiddle second time, it will be WAY MORE simpler to help you.
EDIT: Added media queries example
You need to use a more specific selector to override the initially-assigned CSS attribute.
#media (max-width: 768px) {
div.userProfile div.profileTop {
margin-right:0;
}
}

Sprite Image Resize - Make Responsive when resizing browser

I am having issues making the sprite I have resize, when I resize browser window.
The remiander of the template is repnsive including the Nav Menu.
The sprite remains fixed and sticks out of the page when resizing.
How would I make it size like the rest of the template (removing the width scroll bars)
If you just remove the sprite everything displays correctly.
I have created a Fiddle but its not showing the when I click results.
I have uploaded the page to here:
Test Page
Thank you.
Perfect Solution I have Got U can Use
I have used This solution
And It works Fine on all browser except Android Browser
.playerSp
{
display: block;
background: url(blue_sprite.png) no-repeat;
}
.next-button
{
background-position: -83px -6px;
width: 41px;
height: 46px;
}
var abc=(screen.availHeight+screen.availWidth);
$( window ).resize(function() {
var aaa=($(document).height()+$(document).width());
scale=abc/aaa;
$('#playerContainer').css({ 'zoom': (1/scale), '-moz-transform': 'scale('+(1/scale)+')', '-moz-transform-origin': '0 0 ' });
});
</script>
So I was stuck with the same question and noticed the answer was not yet given here.
Here is the answer:
I've managed to make my sprite fully responsive. For this I didn't use any slicing (photoshop) or javascript. Also notice how the sprites are positioned absolute and yet still responsive according the background.
For a better understanding of this process, please see the following link: http://brianjohnsondesign.com/unlisted/demos/responsivesprite/
Also see my link in order to see how it looks on my website: http://demo.chilipress.com/epic3/
Should my link not work anymore, try the first link above.
See here the CSS and HTML
#sprite1_contact{
background-image: url('sprite_contact.png');
width: 35.2%;
height: 0;
padding-bottom: 7%;
background-position: 0 0;
background-size: 100%;
display: block;
top: 0;
position: absolute;
margin: 0 0 0 32.3%;
z-index: 2;}
#sprite2_contact {
background-image: url('sprite_contact.png');
width: 27.5%;
height: 0;
padding-bottom: 28%;
background-position: 0 27%;
background-size: 100%;
display: block;
top: 0;
position: absolute;
margin: 0 0 0 35.8%;
z-index: 1;}
HTML
<div id="sprite1_contact"></div>
<div id="sprite2_contact"></div>
your sprites have fixed height: 632px; & width: 1163px; if you want them to resize youshould add at least a min-width and a min-heigth properties
example, if you want your sprites resize to a minimum of 10 px lets say you would add those properties to your code
#sprite-main-v2 {
height: 632px;
width: 1163px;
min-height:10px; /*added this line*/
min-width:10px; /*and this line*/
background-image: url(../images/landing-page/landing-sprite-5.png);
background-repeat: no-repeat;
background-position: 0px -700px;
cursor: pointer;
}
you can also use media queries to change the image acording to screen width or height: example:
#media screen and (max-width: 980px) {
#sprite-main-v2 {
height: 100 px; /*new size*/
width: 100 px; /*new size, value just as example*/
background-image: url(../images/landing-page/landing-sprite-5-small.png);/*smaller image*/
}
}
Shrink your sprite to a smaller set size by adjusting its background-position and background-size css properties in a media query.
background-position: 0 -135px;
background-size: 170px 190px;
Those number are an example, you have to play with them to get it to line up with your sprite, which can be confusing as the image can disappear. Recommend adjusting them bit by bit in developer tools.
You can also use percentages to allow for a more responsive resizing, although this can get tricky too.
Note, background-size doesn't work on IE8 but neither do media queries....