On all devices scroll works but not working on iPhone
#media only screen and (-webkit-min-device-pixel-ratio: 0) {
#supports (-webkit-overflow-scrolling: touch) {
body {
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
-webkit-text-size-adjust:none;
height: 1300px!important;
position: relative!important;
background-image: radial-gradient(circle at center , #0c505f, #053540 );
color: #0c505f;
width: 95%!important;
}
When you dynamically add content to a div with
-webkit-overflow-scrolling: touch; that exceeds the div in height, it becomes broken and unscrollable. You can fix this by constantly having
an inner div, that triggers the scrollbar because its 1px higher than
the outer div:
- (Patrick Muff)
.outer {
overflow: scroll;
-webkit-overflow-scrolling: touch;
/* More properties for a fixed height ... */
}
.inner {
height: calc(100% + 1px);
}
Related
I have drawer animated mobile menu with scrollable navigation and fixed footer.
Since fixed element inside transformed element is impossible according to an old issue I applied absolute position to the footer and apply scroll to the navigation container.
The problem is that on IOS 12.1 footer randomly disappears.
HTML
<div class="menu">
<nav class="nav">...</nav>
<footer class="footer">Some footer</footer>
</div>
CSS
.menu {
position: fixed;
z-index: 1050;
top: 0;
left: 0;
overflow-x: hidden;
overflow-y: auto;
width: 100%;
min-height: 100%;
transition: transform .3s ease-out;
transform: translate(-100%, 0);
-webkit-overflow-scrolling: touch;
&.menu-open {
transform: translate(0, 0);
}
}
nav {
position: absolute;
left: 0;
top: 0;
width: 300px;
height: 100%;
overflow: auto;
}
footer {
position: absolute;
bottom: 0;
width: 300px;
height: 65px;
}
UPD
I knew two working fixes:
1. change transform animation property to left, but thats less performant
2. set nav bottom to 65px to not overlap with footer but that's not answers why it's happening
Fiddle
I have a div which I would like to be scrollable, I have added the following code but it doesn't seem to work on iOS devices, works perfectly for Andriod.
I searched and found that adding -webkit-overflow-scrolling: touch; should resolve the problem, however it still isn't allowing me to scroll :/
#media (max-width: 991px) {
.fotorama__nav--thumbs {
height: 180px !important;
}
.fotorama__nav--thumbs .fotorama__nav__shaft {
z-index: 99999;
overflow-x: scroll;
-webkit-overflow-scrolling: touch !important;
}
.fotorama__nav__shaft .fotorama__thumb {
height: 65px !important;
}
}
Any ideas why the above isn't working?
I'm using CSS sprite sheets for a page I'm creating for mobile devices. I've got the layout how I want it, and here's the CSS I'm using for that (this looks fine on Chrome Canary's iPhone 3GS emulator):
div#logo {
background: url('/static/images/iphone/iphone_landing_sprites_small.png') -114px 0px no-repeat;
display: inline-block;
width: 90px;
height: 44px;
display:block;
float:right;
margin:10px;
}
div#stars {
background: url('/static/images/iphone/iphone_landing_sprites_small.png') -114px -46px no-repeat;
display: inline-block;
width: 71px;
height: 12px;
}
div#iPhone {
background: url('/static/images/iphone/iphone_landing_sprites_small.png') 0px 0px no-repeat;
display: inline-block;
float:left;
width: 112px;
height: 238px;
margin-top: 54px;
}
div#separator {
background: url('/static/images/iphone/iphone_landing_sprites_small.png') -114px -60px no-repeat;
display: inline-block;
width: 1px;
height: 53px;
}
Of course, when viewing this on a Retina display the images come out slightly pixellated. I followed the advice in this tutorial for switching sprite sheets for different display densities, and added this:
#media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-resolution: 240dppx) {
div#logo {
background-image: url('/static/images/iphone/iphone_landing_sprites.png');
background-position: -226px 0px;
}
div#stars {
background-image: url('/static/images/iphone/iphone_landing_sprites.png');
background-position: -226px -91px;
}
div#iPhone {
background-image: url('/static/images/iphone/iphone_landing_sprites.png');
background-position: 0px 0px;
}
div#separator {
background-image: url('/static/images/iphone/iphone_landing_sprites.png');
background-position: -226px -117px;
}
}
So now my page still displays fine on the iPhone 3GS simulator (since the #media switch does nothing to it) but when looking at it from an iPhone 4 simulator the images come through as double the size. The layout stays the same (the frames displaying the images are the same size) but the images are cropped so you can only see the top-left quarter of each image.
Is there some other attribute I need to specify to make the images squeeze into the double-density pixels while maintaining the same size on the screen?
I found a solution: instead of defining the new offsets for each element like so:
background-position: -226px 0px;
We just need to 'pretend' that the image is the same size it used to be. So we set the background-size attribute to the size of the smaller sprite sheet:
background-size: 204px 238px;
...and that seems to work!
I've done a fair amount of research on this, but have been unsuccessful in figuring this out. I'm working with a responsive site using the lessframework.css for the responsive grid. It is not properly snapping to any tablet size between 768px and 1024px. When I inspect the elements at that screen size, it appears that the .container is not resizing between those dimensions. However, I don't see anywhere in my css where this is designated to a specific px size, therefore overriding it. I picked this project up from a previous developer, and I am new to responsive code. Any help that can be given would be a huge help. Thank you!
Website is www.mereo.co
Here's a sample of the code from the lessframework.css grid:
/* Default 8-column layout
60 px columns, 24 px gutters, 60 px margins, 768 px total
---------------------------------------------------------
1 2 3 4 5 6 7 8
60px 144px 228px 312px 396px 480px 564px 648px */
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
#if-logged-in {
position: relative;
width: 100%;
height: 24px;
line-height: 24px;
background: #000;
color: #aaa;
font-size: 10px;
z-index: 1000;
}
#if-logged-in .container {
padding-top: 0;
padding-bottom: 0;
}
#if-logged-in p {
margin: 0;
}
#if-logged-in a:link,
#if-logged-in a:visited {
color: #fff;
text-decoration: none;
}
#if-logged-in a:hover {
text-decoration: underline;
}
#if-logged-in a:active {
text-decoration: underline;
margin-bottom: -1px;
}
.container {
/*padding: 0 60px;*/
width: 768px;
margin: 0 auto;
overflow: hidden;
}
#header-image {
padding: 0;
overflow: hidden;
}
/* HEADER IMAGE
full size - 1068x300
8 column layout resized to 890x250 displayed at 648x250
5 column layout resized to 534x150 displayed at 396x150
3 column layout resized to 365x100 displayed at 228x100
*/
#header-image img {
width: 890px;
height: 250px;
margin-left: -121px;
padding: 0;
}
#content {
width: 356px; /* 5 columns */
margin: 0;
padding: 20px;
overflow: hidden;
}
#sidebar {
width: 184px; /* 3 columns */
margin: 0;
padding: 20px;
overflow: hidden;
}
::selection {
background: #c6d8cd;
}
::-moz-selection {
background: #c6d8cd;
}
img::selection {
background: transparent;
}
img::-moz-selection {
background: transparent;
}
the .container { } styles specific to that ipad size and resolution should be inside the media query you have there. So if the container should be 400px wide on an iPad, then your code should be:
/* iPad 1 & 2 (landscape) */
#media (device-width: 1024px) and (device-height: 768px) and (orientation: landscape) {
.container {
width: 400px;
/* all other .container styles specific to the iPad 2 in landscape should go here */
}
#if-logged-in {
/* other styles go in their respective selector in the media query */
}
}
Don't forget that there is an iPad without the retina display, and one with which means if you have any background images or svg images loading from css those should be set to point to the assets that are 2x resolution to look good on retina iPads inside the retina iPad media query.
I've seen a few posts about this but it does not seem to help with the issue I have used <meta name="viewport" content="width=device-width,initial-scale=1" /> in the head but it does not solve the problem of the header and footer not spanning the width of the viewport. The main content area seems work though.
the site to reference is brendanfenn.com
The css is as follows. Any insight is greatly appreciated.
#wrapper {
margin: 0 auto;
position: relative;
}
#header_container{
background-image: url(http://www.brendanfenn.com/wp-content/uploads/2013/02/headerBG1.jpg);
width: 100%;
}
#header {
width:964px;
height:150px;
margin: 0 auto;
}
#content {
width:964px;
background: url(images/border-bg.gif) repeat-y top left;
z-index: 1;
margin: 0 auto;
}
#content #left-col {
width:615px;
float:left;
padding: 20px 11px 20px 10px;
z-index: 1;
}
#content #right-col {
width:307px;
padding:3px;
float:left;
z-index: 1;
}
#footer {
width:100%;
background: #2a2006;
margin: 30px 0 auto;
}
Try setting the width and height values for your body element
body { width: 100%; min-height: 100% }
Another option that may help address the issue is using the #media type, which you can use to specify css values for when a device is in landscape mode.
#media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
body { //values here }
}
<meta name="viewport" content="width=device-width,initial-scale=0.4">
(From the linked file)
is your problem. This is setting your viewport to 800px wide (device-width * 1/0.4).
'width:100%' refers to 100% width of the viewport, i.e. 800px, so everything is working as it should.