I am trying to create a mobile responsive template. I am using the CSS media to find the browser width and it's working fine in most cases.
I want however on a device where the left column will take up too much space for it to jump below the main content on the right.
The solution to get the left down was to use flexible columns to reverse the flow.
This works fine in Firefox, Google Chrome, Internet Explorer and Opera on a desktop.
It doesn’t work on Google Chrome on an iPhone and doesn't work in Safari either on a desktop or iPhone. In both cases the left column appears above the right column.
It works on my friend's Android.
This is the html:
Expand|Select|Wrap|Line Numbers
<div id="content">
<div class="left">
LEFT CONTENT
</div>
<div class="content">
MAIN CONTENT
</div>
</div>
The CSS that sets the values for these blocks on screens of 980 pixels and larger:
Expand|Select|Wrap|Line Numbers
#content {
clear: both;
margin: 0 auto;
width: 980px;
display: inline-block;
min-height: 600px;
}
.content {
float: left;
min-height: 500px;
padding: 10px 10px 0 10px !important;
width: 742px !important;
}
.left {
float: left;
padding: 10px 2px 0 10px !important;
width: 202px !important;
}
The code which control the columns at the correct browser size is:
Expand|Select|Wrap|Line Numbers
#media (max-width: 632px) {
#content { width:603px; display: -webkit-flex; display:flex; -webkit-flex-direction:column-reverse; flex-direction:column-reverse; min-height: 0;}
.content { width:583px !important; min-height: 0;}
.left { width:583px !important;}
}
Any help would be much appreciated.
I used your code to simulate locally. It appears to work just fine on Safari (for Mac, at least). Isn't this the expected behavior? Can you provide images or further details?
It isn't related to your question directly, but I guess you'd better use percentage width instead of raw pixels. If you don't want divs to save a distance between them, you should use margin-right (or left).
Related
Made a website for a friend and he wanted a logo-link in the bottom of the screen. Looks fine on my PC but on his MacBook it is much bigger. Please help.
My CSS is:
img.crossfitnorth {
border-radius: 20px;
width: auto !important;
max-width: 100px !important;
}
This seems to be a pretty standard situation but the HTML/CSS is behaving oddly. I'm in the process of building a profile page for a game and am also looking at mobile responsiveness. I can't seem to get the right-margin to go away. It's not a problem in portrait mode (using a Chrome mobile emulator extension) but in landscape, the div + margin is too wide and a scrollbar appears.
HTML:
<div class="userProfile" style="display:none">
<div class="profileTop">
<div class="profilePicture">
<img src="somepicture.png"></img>
</div>
<div class="profileName"></div>
</div>
</div>
CSS:
.profileTop {
position: relative;
top: 10%;
left: 15%;
width: 70%;
height: 12%;
margin: 0;
}
.profilePicture {
display: inline-block;
width: 12vw;
}
.profilePicture img {
width: 100%;
height: auto;
vertical-align: top;
}
.profileName {
display: inline-block;
position: relative;
font-family:Stencil;
font-size: 1.3em ;
font-weight: lighter;
color: white;
left: 20%;
top: 35%;
}
What's odd is that if I decrease the width of the "profileTop" class, the right margin grows so that the whole thing is the same width. Any help?
EDIT: I can get a workable solution by reducing the width of "userProfile" but it's still bothering me that this won't work as originally intended.
EDITx2: The margin also exists on the "userProfile" div. I suppose the "profileTop" div is following its parent somehow but even if I add margin-right: 0 attributes to both divs, the margin is still there. The parent of "userProfile" is the body.
Error in HTML code, you don't need a closing tag for image.
Secondly, you can use media queries to achieve that. Media queries even have an option for landscape and it's really easy to use. Good luck
#media (min-width: 700px) and (orientation: landscape) { ... }
P.S. Use codepen or jsFiddle second time, it will be WAY MORE simpler to help you.
EDIT: Added media queries example
You need to use a more specific selector to override the initially-assigned CSS attribute.
#media (max-width: 768px) {
div.userProfile div.profileTop {
margin-right:0;
}
}
So im using the foundation frameworks for my wordpress build. I cant seem to figure out why im getting this weird margin or padding on the right side when i drop down to tablet or mobile view.
Anyone ever seen this or know of a fix?
Heres my dev site. if you size the browser down to tablet or phone size and scroll to the left or right it will show up.
I'm using Chrome
body {
background: url(../img/dark-grungewall.jpg) repeat;
height: auto;
}
.site-container {
background: #fff;
box-shadow: 0.5px 0.866px 63px 0px rgba(0, 0, 0, 0.83);
width: 100%;
margin: 0 auto;
}
.row {
margin: 0 auto;
max-width: 100%;
width: 100%;
}
I wanna say the error is coming from my containing divs or body but im not really sure.
http://dev.solarinnovations.com/
This happened to me in the past when using the .row class from Bootstrap. Try putting overflow:hidden in the style part of the wrapper/container class and see if it fixes the issue.
In this part of your code, you set a max-width. This max-width is stopping the site from stretching across the entire window.
.row {
margin: 0 auto;
max-width: 87.5em;
width: 100%;
}
You can fix it by easily using:
max-width:100%;
We have a web page generated via SharePoint 2013 that has a width of 1024. We use the following style on the main content div:
#container_master {
width:1024px !important;
margin-left: auto !important;
margin-right: auto !important;
background-color:#FFF !important;
}
This works well on resolutions greater than 1024. Whenever someone sets their resolution to 1024 (which we have a couple of folks that do that), there is some extra padding on the left and right sides which bring about the horizontal scroll bar.
Whenever I use FireBug, I see the following HTML being generated:
<div aria-relevant="all" aria-live="polite" style="margin-left: 20px; margin-right: 20px; min-width: 1024px;">
This margin of 20px on the left and right is the problem. I found that it can be removed by adding the following CSS:
html body.ms-backgroundImage form#aspnetForm div#s4-workspace.ms-core-overlay div#s4-bodyContainer div#contentRow div {
margin-left: 0px !important;
margin-right: 0px !important;
}
However, whenever I do this, the page is no longer centered on screen sizes greater than 1024. Any ideas on how to make the page "full screen" for those using 1024 resolution while making it centered for those with greater resolutions?
There's a nice trick for this in CSS.
use:
html body.ms-backgroundImage form#aspnetForm div#s4-workspace.ms-core-overlay div#s4-bodyContainer div#contentRow div {
margin-left: 0 auto !important;
margin-right: 0 auto !important;
}
This is the same as:
html{ margin: 0px; margin: auto; }
Sometimes IE won't use margin: auto; To solve this (in some way) add:
body {
text-align: center;
}
But this only happens with old IE browsers.
Use max-width:
#container_master {
max-width:1024px !important;
margin-left: auto !important;
margin-right: auto !important;
background-color:#FFF !important;
}
You need to replace the width property with max-width and reset the min-width:
http://jsfiddle.net/ht2Gc/
div {
max-width: 1024px !important; /* here */
margin-left: auto !important;
margin-right: auto !important;
background-color: #FFF !important;
min-width: 0 !important; /* and here */
}
**A lot of screens have a width of 1024px. for smaller screens the horizontal scrollbar isn't avoidable when you want to have a specific width of your webpage/web application (you might want to consider using min-width and max-width). Unless you are designing your website for a specific browser such as chrome I would advise to make your webpage about 4px smaller. Most web browsers have small borders on the sides, which means a 1024px screen loses a few pixels for your display. Please consider the things said above.
You can probably solve your particular problem with the following css line
body{margin:0;padding:0}
What happens here is that you tell the body to have no padding, which means your website has no extra margin on the sides.
this should solve your problem with the margin. If the scrollbar still appears while you dont want it, then also add these lines to your css:
#media only screen and (min-device-width: 1020px) and (max-device-width: 1030px){
body{overflow:hidden}
}
This checks whether the window size is within certain limits (in this case between 1020px and 1030px), if that is the case, the body will disregard everything that is bigger than the window, thus disabling the scrollbar.
I have a really bizarre issue that I just recently noticed
I'm working on a wordpress theme for a friend, and I'm using relative/absolute positions to add social/connect buttons on the side of some divs -- Which works fine to get the proper design.
The issue, however, arises on the "Social" div that is on the right side of the page.
If the browser is smaller than the main content's size, it adds extra white-space to the right side of page. If I move the div to the left side, it's fine; it only adds the whitespace at about half the page length (which is more confusing).
I can't for the life of me figure out why this is happening; I can't figure out if it's a standard behavior, or an issue I created on my own.
I was hoping perhaps someone here might have had similar experiences, or just an idea how to fix it.
The CSS for the #social div is:
#social{
width: 90px; height: 250px;
padding: 10px;
position: absolute; right: -40px; top: 40px;
background: #EFEFEF;
box-shadow: 2px 2px 5px 0 rgba(0, 0, 0, 0.3);}
The CSS for the #page-content div it resides in is:
#page-content{
clear: both;
min-height: 500px;
width: 870px;
margin: 0 auto;
padding: 20px 0;
position: relative;
border: 5px solid #FFF;
background: #F2F0D7;}
And the screenshot is:
The width up there only exists if the browser's width is less than 960px (the width of the content)
After viewing your site, it looks like it's your social pannel. Some of the generated elements are 100px or more wide. If you remove the width:90px;, you can see the width it's trying to achieve. You could wither amend those elements and set their widths smaller (or to 100% or whatnot), or you could apply overflow: hidden; to the #social div:
#social {
...
overflow:hidden;
}
The reason why this is occurring is because you have overflow out of your social container. It only happens on the right because those elements are left aligned. (you could also align the elements to the right I suppose.)
Hopefully that helps.
As far as I have understood - You want your template to be responsive . For that you need to write media queries to cater various media sizes and resolutions .
/* Large desktop */
#media (min-width: 1200px) { ... }
/* Portrait tablet to landscape and desktop */
#media (min-width: 768px) and (max-width: 979px) { ... }
/* Landscape phone to portrait tablet */
#media (max-width: 767px) { ... }
/* Landscape phones and down */
#media (max-width: 480px) { ... }
write css styling for the different sizes and you can make you website look the way you want .