I am trying to create a mobile site where the body fills the entire viewport.
I've written the following in the styelsheet
html, body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}
however, when using the chrome dev tool's responsive mode, css starts doing weird things.
screenshot
Is this simply a browser bug, or is there something I'm missing here?
Mobile browser do some automatic resizing and some other stuff. You could try to add the following line to your page in the head element:
<meta name='viewport' content='width=device-width'>
This line sets a setting on the viewport, namely that the width of the viewport should always equal the device width.
I am working on a design. The design is located at the link
http://jodbaki.com/apply-now.
In it desktop version is working fine but when. I see it in mobile then the form is going out of the image from right side. How can I adjust it ???.
This is because of your input,textarea and select. Try adding CSS media query once the width is smaller than 400px, shrink all your fields from 150px to 100px.
#media screen and (max-width: 400px) {
input,textarea,select {
width: 100px !important;
}
}
Your
<tbody style="float:right; background:white; margin:12px; width:285px;">
should be a class instead. If showing on mobile, the element doesn't change at all. If you have it as a class (with any name, maybe .applyform), then you can change the CSS for both your desktop version and the mobile version.
The desktop version, you can copy the tbody styles above and make it a class. For the mobile version, I suggest just changing the float:
.applyform { float:none; margin:0; }
Without float, your form will be 100% width.
I want to set different css settings for a certain class for smaller devices than for bigger screens, but my css code is not working as I want it to. I mainly use Bootstrap in my project, but I am also adding some of my own css. For "normal" sized screens I am using this css code:
div.middleDiv{
max-height: 100%;
overflow: scroll;
}
And for smaller devices I want to use the following settings for middleDiv class:
#media screen and (max-width: 767px) {
div.middleDiv{
overflow: visible;
max-height: none;
}
}
My idea is to put scrollbar only on the desired div in case there is an overflow on normal devices (for example computer), but I like the default settings for smaller devices so I want to keep the default settings for those. It seems that I cannot "overwrite" the settings I have for default devices. Can anyone please help me? I will also include screenshots of what I want below. Thank you.
You can access scrollbar property by accessing: ::-webkit-scrollbar .Try below css.
CSS :
::-webkit-scrollbar {
display: none;
}
The problem seems to be the 100% height of your DIV. You could try like this:
div.middleDiv{
max-height: calc(100vh - 20px);
overflow-y: scroll;
}
Try here:
https://plnkr.co/edit/uNqhrweIBJaMsLDRQ9PX
I've been running into issues where I cannot scroll all the way up or down in one swipe on mobile. I'm assuming the issue has to do with a mix of the mobile navigation I created and the url bar on the phone showing and hiding depending on if you're scrolling up or down.
Has anyone run into this issue/found a working solution for it?
The problem disappeared when I changed two rules
#media only screen and (max-width: 850px)
body, html {
min-height: 100vh;
min-width: 100vw;
}
and
html, body {
min-height: 100%;
min-width: 100%;
}
Just use min-height and min-width instead of declaring them explicitly.
Are you using a set viewport?
If you're using something like
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
It could be affecting the way your phone natively scrolls.
img {
max-width: 100% !important; /* Set a maxium relative to the parent */
width: auto\9 !important; /* IE7-8 need help adjusting responsive images */
height: auto; /* Scale the height according to the width, otherwise you get stretching */
vertical-align: middle;
border: 0;
display: block;
-ms-interpolation-mode: bicubic;
}
The above CSS is taken from Twitter Bootstrap which allows for responsive images. The only problem is this has no effect in Firefox and IE.
In the following case:
<div class="row-fluid">
<div id="logo" class="span4">
<img src="<?= get_template_directory_uri() ?>/assets/images/logo.png" />
</div>
</div>
http://dev.netcoding.net/lowsglass/about-us/ - Here is a page showing the problem.
In Firefox or IE, shrink the page to below 432px and you will see that the images do not follow max-width anymore (while above 764px they do).
How can I fix this – without using image containers – to make responsive images work in Firefox and IE?
I've struggled a lot with Firefox / IE and max-width, specifically when on elements of display: inline-block. I use the CSS only solution below to add my fixes.
// Styles for Firefox
#-moz-document url-prefix() {
#logo img {
width: 100%;
}
}
// Styles for IE10
#media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
#logo img {
width: 100%;
}
}
Firefox fails to scale images with max-width/height if width/height is not defined. So there are two ways.
1. Set width and max-width:
width: 100%;
max-width: 100%;
2. Use max-width and max-height in vw and vh:
max-width: 90vw;
What means the image will have max 90% of visible width. Have fun!
Instead of width:auto, try width:100%.
Best,
Cynthia
Actually, the problem isn't the img tag being affected, but the span* containers. When Bootstrap Responsive gets to a certain point, it turns off floating, and sets width to 100%. When that container pops back to 100%, the child within (your img tag) does exactly what you told it to do, which is expand to max-width of 100%.
Look at this from responsive.css... above the declaration in the stylesheet, you'll see this:
/* Landscape phone to portrait tablet */
#media (max-width: 767px) {
[class*="span"], .uneditable-input[class*="span"], .row-fluid [class*="span"] {
-moz-box-sizing: border-box;
display: block;
float: none;
margin-left: 0;
width: 100%;
}
That is what is causing the img to "resize" ... its container no longer shrinks past a certain point, due to the way Bootstrap's responsive styles are set up.
To block this, you could either modify the Bootstrap stylesheet (in which case you will have to redo the change anytime you want to update your Bootstrap files), or you can, in your own stylesheet, do something like the following:
/* Landscape phone to portrait tablet */
#media (max-width: 767px) {
[class*="span"], .uneditable-input[class*="span"], .row-fluid [class*="span"] {
-moz-box-sizing: border-box;
display: inline-block;
float: left;
}
That will put the floating back, however, you're still left with width as an issue, as the default Bootstrap style at that screen-width is trying to set width to 100%. You could try setting width:auto and then hopefully the widths for each specific span-step (.span1, .span2, etc.) will be allowed to take over, but you'll really have to test it out to see what is going to work best for your situation.
Bumped in similar problem after implementing large amount of site design using Bootstrap framework and only Chrome for debug... Biiig mistake © :) It appeared, that cool fluid Bootstrap styles didn't work for images in IE and Mozilla at all. All images were not resized and had original width, sometimes much wider than I've expected to see...
I had a lot of similar places with two columns of divs - span6 for left column and span6 for right one (those are styles for fluid Bootstrap grid). Sometimes in those columns images were placed between text lines, and as you see, images didn't resize well in IE\Mozilla and all of the cool design became not good at all :(
After googling and trying some advices from github I've decided to use jQuery :) I added class to column container (imageContainer for fluid span12 row), and added classes 50perc for images which I needed to resize properly (size of each image should be 50% of container's size). And here's the code:
$(function(){
var cont = $('.imageContainer');
$('.50perc').each(function(i, el){
$(el).width(cont.width() / 2);
});
p.s. Actually it will be much effective to use this function in window.resize event handler :)
Ran into the same problem and still haven't found a fix or CSS only hack, except for forcing width: 100% at small browser sizes, when the natural width of the image will usually be larger than the width of the page (here I've assumed I don't have any images narrower than 480px):
img
{
width: auto;
max-width: 100%;
height: auto;
}
#media screen and (max-width: 480px), only screen and (max-device-width: 480px) and (orientation: portrait)
{
#-moz-document url-prefix() {
/* Firefox doesn't respect max-width in certain situations */
img
{
width: 100%;
}
}
But that will still force images that have naturally smaller widths to get blown up, which is bad. So at that point, if Javascript is feasible or already in use, I would add this to hit every image:
PSEUDO CODE:
$('img').css('max-width', this.actualFullSizeWidth + 'px');
...which should override the CSS max-width rules, and guarantee the image doesn't get larger than it's actual width.
Responsive images for Firefox, IE, Chrome. Simple solution that works in Firefox
<div class="article"><img></div>
.article {background: transparent 0% 0% / 100% auto;}
.article img {max-width: 100%;}