I made a website for fun & testing but it doesn't look well on mobile as it works on desktop, especially images and specially positioned stuff got out of page. I tried
<meta name="viewport" content="width=device-width, initial-scale=1">
but it still looks a way that nobody wants to see.
I'm a newbie codder please forgive my flaws :)
website: http://ersinski.epizy.com/
<meta name="viewport" content="width=device-width, initial-scale=1">
in your css file:
img {
max-width: 100%
}
It's because you are centering things with left: 500px;. It's a fixed distance from the left side that will only look centered on a specific screen size. For example on a device with a screen width of 320px(mobile) all your 'centered' elements will start 500px from the left side even if that means going beyond the device screen.
For dynamic design look into flexbox.
And for your specific website:
Remove all the left: 500px; on 'centered' elements
Add display: flex; and flex-direction: column; to your body element
Add align-self: center; to anything you wanna center horizontally.
Related
At some point I know I need to bite the bullet and do some serious reading on responsive and adaptive design, but I was hoping there was a really simple way to address this issue.
I have the following web page, shown here in my desktop browser.
And here is the same page on my cell phone.
Although it's probably hard to tell here, the banner is too small when viewed on my cell phone.
Ideally, I would like to have it so:
The width of the page content (and the corresponding width of my <footer> element, which has a top border) does not take up the entire width of the browser when it's full screen on the desktop, but does take up the entire width of my cell phone.
The banner would never be bigger than the pixel width of the image on my desktop, but would take up the entire width of my small cell phone.
Is there any simplified approach to this?
You can use media-queries to handle style changes based on the viewport. For instance, you can do something like:
JS Fiddle Example
/* Desktop Styles here*/
footer {
background: blue;
width: 500px;
}
.banner > img {
width: 300px;
}
/* When the screen is smaller than 560px, specify what properties you wan to change. */
#media only screen and (max-width: 560px) {
footer {
width: 100%;
}
.banner > img {
width: 100%;
}
}
Apart from media queries which you should seriously look into for serious responsiveness, you will also need to adjust the viewport meta tag in your header.
Add <meta name="viewport" content="width=device-width, initial-scale=1"> to your <head> tag to instruct the phone browser not to attempt to display the page as in a zoomed-out state.
So, for instance:
...
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
<title>Hooray Banana</title>
<meta name="keywords" content="This page is a placeholder for future content.">
<meta name="description" content="sc web group">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
...
Then F12 and view in a phone emulation mode or check on your phone directly.
I have a webpage as linked:
Click Here
Everything is fine on PC or MAC. The issue is if you look at it on a mobile devices, you will find that the 3 images caused a horizontal scroll bar.
I use this to set the viewport for mobile device consideration:
<meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=320, maximum-scale=1.0, user-scalable=no">
I use a sprite method to set the div background, for showing the 3 images.
HTML:
<div class="demopic" id="category"></div>
CSS:
.demopic {
text-align: center;
margin: 10px auto;
background: url(http://7te8e7.com1.z0.glb.clouddn.com/sprite_instructions.png);
}
#category {
width: 560px;
height: 590px;
}
My question is, based on my situation, is there a quick fix to achieve a responsive image? I don't want to show the horizontal scroll bar on mobile devices.
If I delete initial-scale=1.0 in <meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=320, maximum-scale=1.0, user-scalable=no">, the image will be compressed for a proper size, but at the same time, the font-size will be resized as well.
Anyone give me some inspiration will be highly appreciated!
I think you're best bet is to use the standard img tag and make sure the image never expands wider than it's parent container (could just be the body element).
.my-image {
max-width:100%;
height:auto;
}
This should do the trick.
However, if you really want to use the div / background image approach things are slightly more complex.
.my-background-image {
width:100%;
height:0;
padding-bottom:50%;
background:url(img.png) no-repeat center center;
background-size:100% auto;
}
Here we set an element to fill it's parents width. Then we make it's height proportional to it's width using padding-bottom (you'll need to tweak this). Finally we make the background size always fill the element. Worth noting that background size won't work in IE8.
I build an html landing page, you can see it here
I used the meta viewport tag in that way:
<meta name="viewport" content="width=device-width">
When I enter to this page from the mobile, the page width that not fit to the screen,
Iphone example - http://mobiletest.me/iphone_5_emulator/#u=http://tzabar.exactive.co.il/
what I've done wrong?
As per War10ck's suggestion consider changing your viewport meta tag to something like the following:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
You can also make changes in your CSS to help you along. Consider changing the .content class. For example:
.content{
width: 100%;
max-width: 930px;
}
I'm not sure what your ultimate design goal is, but that should get you moving in the right direction. You could also look into something like Bootstrap http://getbootstrap.com/ to help you make sites responsive.
Firstly, follow the good advice from jmadden and change your viewport tag to something like
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Then at line 54 of style.css you have:
.content {
width: 930px;
margin: 35px auto;
}
You need to remove that 930px width or override it with media queries because at narrow viewports it's preventing your page layout from collapsing.
Hope this helps
I have a page i've created which works fine in a desktop but get's messed up in a mobile browser.
This is the mobile version. I have a header and a .container(the one with gray background) set to width 100%. Inside .container i've a .wrapper set to width: 900px; and margin: 0 auto;. Why is the blue background and the gray background rendering till about half of the page witdh? What is the best way I can approach the problem to create a page like the desktop version on the mobile as well?
I believe your wrapper may be causing the issue. Instead of setting a fixed width for the object do:
.wrapper {
max-width:900px;
width:100%;
display:block; //for centering
margin:0 auto // for centering
}
Should solve your problem and make the website more responsive throughout different platforms.
Good luck! :)
NOTE
If you are not already doing so, take rajkumar's comment and add:
<meta name="viewport" content="width=device-width, initial-scale=1">
It's your wrapper and li width. Set them to percentages.
.wrapper {
width: 90%;
margin: 0 auto;
}
li {
width: 30%;
....
}
if you want create a site for both desktop and mobile..Try all width in percentage.because percentage only fit width automatically according to screen resolution.suppose you give in pixels the screen was not adjustable in all screen resolutions.its only fix according to your size only.
In your case please make sure for all width in percentage.
and also please conform the media type for get screen width in header section
<meta name="viewport" content="width=device-width, initial-scale=1">
I had wide length table with using twitter-bootstrap.css.
The content was sticking out from the edge of the table so I added this line to bootstrap.css.
min-width: 400px;
bootstrap.css
body {
min-width: 400px;
padding-top: 60px;
padding-bottom: 40px;
background-color: #27292b;
background: url('/assets/body-bg.jpg');
}
But now, When my smart-phone loads the page, initial looks zoomed up as default.
How can I make it fit?
index.html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
With bootstrap, it is not straightforward to show tables with large amounts of content, especially on mobile devices.
First think about how much content is needed on a mobile device, and if still a problem, you can increase the size of the mobile viewport by reducing the initial-scale in the viewport meta tag as so:
<meta name="viewport" content="width=device-width, initial-scale=0.5">
This would double how much you could see - adjust the initial-scale value as appropriate.
Have a look at http://twitter.github.com/bootstrap/scaffolding.html#responsive if you want to find out how to hide some of your <td> elements on mobile devices.