I am curious about an odd rendering behaviour on Safari 5.1. In a two-column layout, the first column has a fixed width, and the second one should take the remaining part.
HTML:
<div class="row">
<div class="left">
<p>Left</p>
</div>
<div class="right">
<p>Right. Some more text here, to show how odd the line breaks...</p>
</div>
</div>
CSS:
.row { width: 300px; background: yellow; overflow: hidden; }
.left { width: 100px; background: red; float: left; }
.right { margin-left: 100px; background: green; overflow: hidden; }
This works great on most browsers (on all "modern" browsers, as I thought), but now I found out, that Safari 5 adds an unintended right margin on the second column of the same width as the intended left margin (as if there were a .right { margin-right: 100px; } rule).
http://jsfiddle.net/MvF3V/1
Most Browsers:
Safari5: (tested on 5.1.7, but it occurs also on 5.1.9)
When I remove the overflow: hidden; it works fine, but I need that for other inside elements.
My questions is not how to rearrange this little example, but:
Is this a Safari-5-Bug, or are my CSS rules somehow wrong, even if they "work" on most browsers?
If it is a Bug, does it have a name, with which I can google some workarounds?
Can I detect somehow, which Browsers are affected with this behaviour, to define some exception rules for them.
Update: The standard Android browser (Galaxy S3, AppleWebKit 534.30) seems to use the same old webkit engine. The same strange right margin appears: http://jsfiddle.net/MvF3V/1/embedded/result/
Give a
padding-left: 100px;
instead of
margin-left: 100px;
This seems indeed to be a bug in older Webkit versions. I found another question about the same issue.
There are workarounds. The most obvious is to avoid overflow: hidden to clear floats, and to use clearfix instead.
Since nobody answered to my questions, I try to give them myself:
Is this a Safari-5-Bug?
It's a Webkit Bug
If it is a Bug, does it have a name, with which I can google some workarounds?
No name found, apparently there are not many people who layout websites as I do... (and still want to support old browsers).
Can I detect somehow, which Browsers are affected with this behaviour, to define some exception rules for them.
If you really want to define exceptions, you can make such ugly things in JavaScript
var webkitCheck = /AppleWebKit\/([0-9.]+)/.exec(navigator.userAgent);
if (webkitCheck) {
var webkitVersion = parseFloat(webkitCheck[1]);
if (webkitVersion < 535) {
jQuery('html').addClass('oldWebkit');
}
}
< 535, because 534.59.10 is the Webkit version of the latest Safari5 version, and in Safari6, this bug does not occur anymore.
But thanks, #Era and #NoobEditor for your comments.
Related
I'm trying to position elements in a way so that when the browser width is changed, the webpage will scale everything in proportion, but what happens is that they shift a little. I don't understand why. I can adjust this okay using media queries, but they change drastically in mobile browsers. To illustrate what I'm talking about, I created an example in which I'm trying to keep this black text centered inside this green box. From my example, you'll see that scaling the browser on a desktop will keep the text in the box centered pretty well, but when switching to a mobile browser, the text will go out of the box. What can I do to keep it scaling correctly?
I realize that I can just fill the text div with a green background, but you have to understand that this is just an example of what I'm trying to do. The real webpage is much more sophisticated, so that will not be an option. I need to make sure that these divs scale appropriately. Thank you.
I provided an image to show the problem that I'm getting in my phone browser. It's a bit small, but you can see how the black text dips below the green box.
The example website: http://www.marifysworld.com
CSS:
#viewport {
width: device-width;
zoom: 1.0}
#-ms-viewport {
width: device-width}
body {
margin: 0px;
padding: 0px;
background-color: #fffff}
img {
display: block;
margin: 0px;
padding: 0px}
.text {
font-size: 2.25vw;
color: #000000;
text-align: center;
text-size-adjust: 90%}
.box {
width: 23.75%;
height: auto;
position: absolute;
left: 25%;
top: 40vw}
.divtext {
width: 20%;
height: auto;
position: absolute;
left: 26.75%;
top: 42.5vw}
HTML:
<img class="box" src="http://www.marifysworld.com/images/platform/box.jpg" />
<div class="divtext text">
Why won't this div of text stay in the center of the block in mobile browsers?
</div>
Well, you are using positions for your design but it is confusing and not possible.
Here is an idea to make this design work.
Just try it...
HTML:
<div class="box">
<div class="divtext text">
Why won't this div of text stay in the center of the block in mobile browsers?
</div>
</div>
CSS:
#viewport {
width: device-width;
zoom: 1.0}
#-ms-viewport {
width: device-width}
body {
margin: 0px;
padding: 0px;
background-color: #fffff;
}
.box{
background: url('http://www.marifysworld.com/images/platform/box.jpg');
width: 23.75%;
margin: auto;
margin-top: 20%;
}
.divtext {
width: 90%;
padding: 5% 0;
margin: auto;
}
.text {
font-size: 2.25vw;
color: #000000;
text-align: center;
}
Update: initially I thought the problem might be the (not universally supported) text-size-adjust property, but it seems this is unlikely. I leave those thoughts below just in case they are useful to someone else using that property.
Having been unable to reproduce the problem myself but seeing the useful image now put into the question I think we have to look at the actual font and how it is sized and using space. There are quite a few factors which maybe the browsers are setting different defaults for. Here's a few, there may well be more:
font-family - most obvious but is whichever browser is causing the problem using the same default font as browsers not causing the problem? Try setting a specific font and see what happens
Different fonts will take different widths for different characters. Try a monospace font - that will probably overflow - just to demonstrate the issue
kerning - no I don't fully understand how different fonts use it and what they mean by 'normal' (which is probably the browser's default) but that will also alter the space used as will...
..line height - perhaps that needs to be specifically set
font-weight will alter the space used - do all browsers/systems interpret say 400 exactly the same way
I guess there's loads more that may differ between browsers - for example how exactly do they calculate the spacing needed to center text, will they always break a line at the same place etc.
Sorry this is a waffle, but there are so many factors that could make the text overflow and I don't understand them all in enough depth.
Basically what you need is to be able to scale the text div to force it to fit - for that you would need a bit of JS I think (?or is there an equivalent of contain for divs?)
ORIGINAL STUFF:
I am seeing text stay within the green box on a mobile device (IOS Safari) so I imagine the problem you are having is with another mobile device/browser such as Android.
If this is case the area to look at is the use of the CSS property
text-size-adjust: 90%
There are a couple of things to note here:
According to MDN
This is an experimental technology. Check ... carefully before using in production.
This property is intended to be used in the case where a website has not been designed with smaller devices/viewports in mind.
According to MDN, while Chrome on Android implements text-size-adjust fully, Firefox on Android and Safari on IOS do not support the percentage version.
I may be missing something but the question explicitly states that 'the webpage will scale everything in proportion'. Apart from possible inbuilt browser margin and padding on the div, everything is expressed as vw or % so I cannot see anything else that would have an adverse affect on the text positioning.
I also cannot see why this property is being used. It may or may not be causing the problem, but it certainly may affect how text is displayed on some browsers and it seems to be, at best, redundant for a site that is designed with proportionality in mind from the start.
I swear this used to work correctly and it still works correctly in Safari under iOS, but for some reason it's broken in Chrome and apparently (as per our client) in IE 11.
The basic setup is here:
http://codepen.io/mattlacey/pen/BpEvWE
With transform: translateZ(0); commented out then everything that's initially offscreen is never rendered, with it, hardware accelerated rendering is enforced and it is rendered. The issue now is that even though it's rendered the elements can not be intereacted with. I've setup two onclick inline scripts, one on "A.L.C" and one on "KAREN WALKER EYEWEAR". Clicking the first works, while the second does not, because it's in an element that's only displayed because of the transform.
Is there a known work around for this issue?
If it is possible for you to edit the HTML, with a little extra markup, it could be resolved wrapping the .filter-values-indexed div in another element and applying the overflow to this new element.
HTML:
<div class="wrap">
<div class="filter-values-indexed">
[...]
</div>
</div>
CSS:
.wrap{
overflow-x:scroll;
}
.filter-values-indexed{
width:100vw;
column-width: 200px;
max-height: 250px;
}
I am not sure why this is happening, but if you remove the overflow-x and transform properties, the offscreen content becomes clickable.
.filter-values-indexed{
column-width: 165px;
/*overflow-x: auto;*/
max-height: 250px;
/*transform: translateZ(0);*/
}
This horizontal scrollbar will move to the bottom of the page. Depending on your specific needs this could be a temporary fix.
I'm worried that the short answer to this question is NO.
But before I accept this fate I'll attempt a last ditch effort.
Usability concerns aside, is there any way I can do a div overflow for webkit mobile where, when scrolling, I do NOT see the scroll indicator?
I'm really hoping to avoid building a custom scroller in plain JS just because apple insisted on forcing the indicator to always be visible.
Any pointers much appreciated. I've looked around a lot but found nothing useful.
Reminder: I'm not asking about scroll bar customization!!! I'm asking about the indicator that shows during touchmove.
I think you can use this code. But this will only work in Chrome and Safari.
#element::-webkit-scrollbar {
display: none;
}
Technically you could do this in Chrome and Safari using the following CSS:
body::-webkit-scrollbar { display: none; }
However, for all other browsers you'll need Javascript. The basic algorithm would be as follows:
HTML
<div id="container">
<div id="content">Hello, here's lots of text...</div>
</div>
CSS
#container {
overflow: hidden;
width: 100%;
height: 100%;
position: relative;
}
#content {
position: absolute;
left: 0px;
top: 0px;
}
JAVASCRIPT (pseudo-code)
When clicking on #content, check for drag
If dragging then measure amount and invert amount
Set that amount to top position of #content
Keeping with my tradition of answering my own question after extended research, the indicator can be hidden only by removing -webkit-overflow-scrolling:true CSS attribute.
This, unfortunately, also removes the spiffy scroll-elasticity feature, which is of course whey one would want to use the above CSS.
I am having problems having "extra space" at bottom of page. in Opera, and firefox. and on IE, sometiems it happens sometimes it doesn't on chrome works fine all the time. I am new to css and html5, and on top of that. haven't done any web design in a lot of time. used to just use tables and old html. the website i'm having problem with is
http://jconstruction.us.cloudlogin.co/index2.php
I tried everything and now i gave up. it is a modified template the templates works well in all browsers so my guess is is some of my modification. the template where i having problem is from here http://www.jonathansconstruction.com
if anyone can help will be glad.
Thanks in advance I am really needing this spent lot of time with no success
Edit
Thansks a lot for all the HeLP ..... I did manage to fix the problem on most browsers, However, still having a hard time on IE, if anyone can help will be greatly appreciated (already about to pull my hair out ) lol.. I even tried validating. and although some errors, i tried taking the errors aout and still, same result.
This is because you might have used top:-***px; in the CSS for any <div>. Try using absolute positioning.
I found the issue, set this property
.ui-datepicker
{
position:absolute;
}
To do this, I usually create two parts to the page:
<body>
<div id="main-part"></div>
<div id="footer"></div>
</body>
Then style it:
#main-part { height: 100%; padding-bottom: 110px; }
#footer { height: 100px; margin-top: -100px; }
Try using fixed headers and footers in a div with the 100% height, so that the space will not mess up in any browsers. If you can try over position:relative also and try setting margin-top values for the space.
I also had the same issue. I found the solution by making change in the CSS:
.Zebra_DatePicker.dp_hidden {
visibility: hidden;
filter: alpha(opacity=0);
-khtml-opacity: 0;
-moz-opacity: 0;
opacity: 0
}
Instead of visibility: hidden; use display:none; and it will work perfectly.
HTML:
<td align="center" width="100%">
<a class="Forum_ib_moderate" href="Default.aspx" title="Moderate"></a>
<a class="Forum_ib_admin" href="Default.aspx" title="Admin"></a>
...
CSS:
A.Forum_ib_moderate:link, A.Forum_ib_moderate:visited, A.Forum_ib_moderate:active, A.Forum_ib_moderate:hover
{
background-image: url(images/ib_moderate.png);
background-repeat: no-repeat;
background-position: center;
padding-left: 2px;
padding-right: 2px;
padding-top: 8px;
padding-bottom: 0px;
height: 35px;
width: 35px;
display:table-cell;
}
A.Forum_ib_admin:hover
{
background-image: url(images/ib_admin_hover.png);
}
the menu looks just fine in IE, shows up vertical in Firefox. If i turn off "display:table-cell;" style in Firebug and then turn it back on, it fixes that menu node.
any ideas?
p.s.: i don't want to mess with the menu itself, since it's a part of a DNN Forum 4.4.3. I'd rather fix the CSS to make it show correctly.
Actually I think you'll find that IE works because it ignores display: table-cell. Display: table-cell is actually you're problem.
What I'm guessing is happening is that IE is reverting those to be inline element, hence horizontal.
Change it to:
display: inline;
add some padding (left and right) as necessary and you'll get what you want.
Alternatively you can float them (left and/or right).
Besdies, they're already in a table cell. Table cell display inside that is a bit wrong.
We've run into this issue as well. Still looking for a solution. In our case, we need to keep display: table-cell layout.
It appears Firefox sometimes and seemingly randomly, will cause table-cell objects to wrap rather than act like an actual table. A REFRESH fixes it, which just makes it that more difficult to bug fix.
Seems to be a simple FireFox bug. I encountered the problem the other way around: The DIVs with table-cell arranged below each other after the refresh in FF 3.5.9 on Win XP.
I was not able to not find any solution (wrap the cells into a row, overflow hidden, etc) but to update FireFox to 3.6.3 and hope there are few users with that version.
This sounds similar to a firefox reflow bug that I'm trying to fix as well. Apparently tables are really bad for rendering, since they cause a reflow and it seems that Firefox sometimes misses the reflows.
I found the following pages to be helpful:
http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/
http://www.mozilla.org/newlayout/doc/reflow.html