Small world map? - leaflet

I am using leaflet.js to render tiles from openstreetmap. I have it working fine. I would like to display the entire world map (zoom level 0). This also works fine. My problem is that on zoom level 0 the world is kind of big. Is it possible to render the world map in a div 100px wide, for example?

if you want to change the width or height of the div containing the map, use CSS,
like this:
<style>
#map{
width:100px;
height:300px;
}
</style>

Related

How do you make a css tiled / repeated background stay sharp on a retina screen?

On the web page, I'm scaling all of my images by 50% with CSS to make them look sharp on retina screens but that doesn't work for tiled images, there seems to be no way to scale a tile background image so that it will be sharp and not doubled sized on the retina screens. Sorry if this question is confusing.
Setting background-size: 150px 150px; for a 300x300 background image seems to do the trick. Note that background-size: 50%; will not do what you might expect, as it sets the width and height to 50% of the parent container.
I haven't worked with Retina displays, but I would imagine it would be better to create an alternate background image with higher resolution for them.

CSS min-height is fighting background-position

For the problematic behavior, try resizing the window of this web app. Thought the header and boxes stop being resized after a minimum dimension, the background image continues to position itself at the center of the page, which looks really stupid.
Here's the relevant code for the background image:
body{
text-align: center;
min-width:1000px;
min-height: 600px;
background: url(../images/road_newtry_tile4.jpg) 50% 50% fixed;
}
Even though background-position isn't nixing the min-width and height (ie, the window will stop resizing after predetermined dimensions, it continues to center the background image.
Why is it doing this? How can I prevent the image from re-centering after certain a certain point?
it is doing it because the 50% is relative to the size of the browser window. A fix would be to instead have the background image on a wrapper div, which has the min-width and min-height set.

mobile website - iphone div position

I am developing a mobile website. An issue im running into is positioning some divs.
(testing on iphone 4 atm)
http://rerender.tv/phoenix/m
I have a couple of divs that are suppose to be placed at the right of the viewport (right top and right bottom)
the divs are set with
position:absolute;
right: 3%;
top: 3%;
But on the iphone it looks like those divs get placed towards the middle.
Also on the subpages, theres a div container that holds content with the width set to 95%, but the content (text) only goes half way in the viewport.
http://rerender.tv/phoenix/m/about.html
Not sure what the issue here is but it looks like the page width is not scaling to the full size of the viewport. Although the meta tag is declaring the scaling at 1 and the size of the viewport to be device content.
Searched around, couldnt find anything. But i think im just overlooking something.
Help?
thanks

Single/sub pixel misalignment of divs on ipad and iphone safari

I've got the following situation, and I need some help...
Two divs, same size, same location, one on top of the other
Everything works as expected on desktop browsers
On the iphone/ipad a faint line appears around the border of the divs
This faint line is not always on all four borders. It changes depending on the location of the divs. It looks to be happening as a result of the two divs not lining up properly, but according to their style settings, they are of identical size and location.
You can see the results here: http://www.thoughtartistry.com
Any ideas?
I had a similar problem in a recent project where I had background image masks with different background color to colorize the resulting icons in mobile Safari. The problem was that when the page was scaled down by Safari, there was a line of the background color showing around the image, even though it should have been masked. I never found a way to prevent that leaking of the background color when the page is scaled down. It's clearly an error in mobile Safari's algorithms that recalculate the background and mask. I did find a workaround: I put an outline on the element with the same color as the background of the element's parent. The outline is outside the element and therefore masks the part bleeding out. If your element's parent has a pattern background that's drastic, this won't work that well, but if it's a solid color, it'll do just fine.
A negative margin is the only way I found to prevent this.
For example, if you have a faint horizontal gap between 2 divs, adding a top margin of -1px to the second div will make it overlap slightly and the gap will not reappear as the page is scaled.
Some situations (like image sprites or repeat patterns) may need a little more tweaking, but the general idea is the same. For a sprite, make sure there is no big color change within 1 pixel of the cropping border. The bleed is never more than 1 pixel, so a 1 pixel adjustment is enough.
The problem is not only with divs matching together, but also with image sprites.
I followed the advise in this thread of setting initial viewport scale to 1.0. The sub-pixel bug was gone, but then I tested my website on other devices, like Android, and realized a full size page is annoying, since users have to re-scale every time it's loaded. So I preferred to disable the scale and wait until Apple fixes it. Then one day I was thinking how to solve the problem with the margins of the page, and I came to this simple solution in CSS:
html {
min-width: 1024px;
}
Devices capable of this resolution, such as iPad in horizontal position, will set the document scale to 1.0. In my case this is enough solution, since I can show the page is working just right, and the sub-pixel bug is in Safari/iOS, which will be solved in the future hopefully.
It totally depends on one's situation, but in our case we use negative margins as proposed by this thread or a box shadow since outline only applies to all borders and ie. outline-bottom does not exist.
/*
* Prevent faint lines between elements.
* #link http://stackoverflow.com/questions/5832869
*/
box-shadow: 0 1px 0 red;
I also solved the iOS sub pixel gap issue (on a full screen site) by using overflow-x: hidden; to stop side ways scrolling & viewpoint scale to stop pitch zooming. I also had holder divs set at width: 101%; and all the elements/image divs inside set to float: left;. This means the sub pixel gaps are all on the left hand site but pushed out of view by the holder div set at 101% width.
Remove "clear:both" (if there is) from div below the gap.
I also had to solve this. If you are using Div's to define sections only then.
//background.css
.background-color {
background-color: blue;
}
.background-color div {
background-color: inherit;
}
I'd try playing with meta/viewport options, specifically setting initial scale to 1.0 and disabling user zooming.
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

Why does the iphone make my text big when I flip it over?

I have some divs as headers on a page and then text underneath them. When I flip the phone over onto its side the text suddenly becomes inflated even though there is no CSS to do this.
What could be doing this?
When the iPhone is held in portrait, it has a width of 320 pixels (or 640 on the iPhone 4). When it is held horizontally, its width is 480 pixels. The “zoom” effect you’re describing is MobileSafari redrawing the text for the larger width.
I find out, that if div have enough place to large inner text, text will be bigger. But if div is inline element or just have no free space, text will not be scaled after iPhone rotation.
Try setting the viewport using the following meta tag:
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
Hope this helps. It helped me getting a consistent mobile page.
Bob
Right i got it...
Basically even when I set the viewport sizings it still messes up. to stop this happeing I have placed the elements in a div with a fixed width of 320px.
That way the text size is in the same size div when horizontal or not..
Cheers
Pete