I have a few different stylesheets and one has #media queries that for some reason are being loaded regardless of screen size in IE. The #media queries were in my main Site.css file so I moved them to a 'new' stylesheet for all browsers. If put them in an IE specific stylesheet and remove them from all other stylesheets then everything works as planned since i'm targeting IE10 with the JS that adds the ie10 class if the correct browser loads so i'm good. Problem is that i need those #media queries for things to work on all other browsers and since IE10 and above have stopped using conditional statements i cant exclude the 'new' stylesheet by using the <!--[if !IE] comment.
If i use:
<!--[if !IE]>
<link href="#Url.Content(string.Format("{0}/css/search-media-queries.css", Model.RequestAuthorityUrl))" rel="stylesheet" type="text/css" />
<![endif]-->
It seems to work on all IE but it doesn't load the stylesheet in the other browsers. The syntax for the location of the stylesheet is a little odd but theres a purpose to that and it has nothing to do with the issue so i dont want to clutter this question wit
Any advice on how i should go about adding these styles to all browsers EXCEPT ie and then i can have them in the IE specific stylesheet so they wont load right away and break my layout. I understand this probably sounds confusing and was a difficult bug to finally figure out because i also couldn't see my code in the IE inpsector to debug so i had to just take out CSS until i finally noticed what it was.
ORIGINAL ISSUE:
What was happening is that i have a div with some inputs and have made that div responsive and tweaked with #media queries. If i load the page the div and it's contents are displayed as if already using one of the #media queries although the browser size is outside of the scope of the #media queries. If I resize the browser (make it smaller) and then i set it back to fit the full size of my screen then the correct layout is applied.
UPDATE CSS CODE EXAMPLE:
#media screen and (max-width: 1222px)
{
div#spiSearchWidget
{
width: auto;
}
div#spiSearchWidget #spiStartDate
{
margin-right: 20px;
margin-bottom: 0px;
}
div#spiSearchWidget .endDate
{
}
div#spiSearchWidget .adultLbl
{
margin-right: 58px;
margin-left: 20px;
}
div#spiSearchWidget .childLbl
{
margin-bottom: 0px;
}
div#spiSearchWidget select#Children
{
margin-left: 10px;
}
div#spiSearchWidget #spiSrchBtn
{
clear: none;
margin: 20px 70px 0px 70px;
}
}
#media screen and (max-width: 1104px)
{
#spi-walkin-searchbox .availContLrg
{
width: 20%;
}
div#spiSearchWidget
{
width: auto;
}
div#spiSearchWidget #spiStartDate
{
margin-left: 20px;
margin-bottom: 10px;
}
div#spiSearchWidget .endDate
{
clear: both;
margin-left: 10px;
}
div#spiSearchWidget .adultLbl
{
margin-left: 42px;
clear: both;
}
div#spiSearchWidget .childLbl
{
clear: both;
margin-bottom: 0px;
margin-left: 34px;
}
div#spiSearchWidget select#Children
{
margin-left: 10px;
clear: both;
}
div#spiSearchWidget #spiSrchBtn
{
clear: both;
margin: 20px 20px 0px 20px;
}
}
All of that is loaded from the beginning for some reason.
Your problem isnt about excluding stylesheets, it should be about getting it to work properly in all modern browsers. They removed conditional comments for a reason.
IE10 is not bad at rendering. Ive personally never had an issue with responsive code and IE9+. Maybe post a snippet so we can see how you're doing it?
I found this helpful, from http://www.impressivewebs.com/ie10-css-hacks/
if (/*#cc_on!#*/false && document.documentMode === 10) {
document.documentElement.className+=' ie10';
}
Related
I have this stylesheet in a polymer component:
<style include="app-grid-style">
:host {
--app-grid-columns: 1;
--app-grid-gutter: 10px;
display: block;
margin: 0 auto;
}
#media only screen and (min-width: 768px) {
:host {
--app-grid-columns: 2;
--app-grid-gutter: 15px;
}
}
#media only screen and (min-width: 1170px) {
:host {
width: 90%;
--app-grid-columns: 4;
--app-grid-gutter: 30px;
}
}
paper-button {
margin: 0;
min-width: 0;
text-transform: none;
color: var(--app-dark-primary-color, black);
}
.header {
#apply(--paper-font-headline);
color: var(--app-dark-gray-color);
}
.header-icon {
float: right;
font-size: 15px;
vertical-align: middle;
}
p {
color: var(--app-light-gray-color);
}
</style>
Ok, it seems the media queries are fine, because if I resize the browser and refresh, I see the page with the changes or if I access to the page from my iPhone, I see the site for smarphones.
However, I think I must see how the css change the page when I resize the browser without I have to reload the page.
Are there any bug in my stylesheet?
Ok, i have found the solution in polymer documentation. I think it's a bit hidden:
"For browsers that don't support custom properties, call Polymer.updateStyles() to re-evaluate the media queries upon window resize" - For more information: https://www.polymer-project.org/1.0/docs/release-notes#v-1-6-0
Analyzing the example in documentation, I have found they call that method in attached function on polymer element.
I have tried this fix and it's works!
I have tried 100 different ways to get the footer to stick to the bottom of the page. On all my other pages, it operates fine however on one page, the footer floats to the middle. This is the code I am trying to work but clearly something is off.
#media screen and (min-width : 768px) {
.page-id-94 html, body {
display: none;
}
.site, .site-content {
height: 100%;
}
#boldgrid-sticky-wrap {
min-height: 100%;
height: auto !important;
height: 100%;
}
}
I need this to execute in mobile/smaller screen versions only therefore I used the media query.
I am learning CSS as I go so all this is very new for me. All help is appreciated
Not sure what you're trying to do here, but this is how I usually do my footers:
.footer {
position: absolute;
bottom: 0;
width:100%;
height:20%; //you can hard code a px value for this
padding: 5px; //you may wish to change this as well
}
this is not sublime problem, my code
#media(min-width:801px){
margin: 0 auto;
margin-top: 40px;
margin-left: 370px;
}
shows in sublime the margin is in white color.. then I test in my browser, and as expected, the css doesn't apply.. the syntax above should be fine.. what is this happen?
You need to define a selector within the media query, e.g.
#media (min-width: 801px) {
body {
margin: 0 auto;
margin-top: 40px;
}
}
http://jsfiddle.net/g7MVx/2/
You aren't applying those margins to any elements. A media query wraps around regular CSS selectors like so:
#media (min-width:801px) {
.myClass {
margin: 0 auto;
margin-top: 40px;
margin-left: 370px;
}
}
Refer to MDN's CSS media queries page for more information.
#media only screen and (max-widht: 510px) {
.nav__ul {
display: none;
}
}
Same problem, trying to apply this code, the ""max-widht doesn't appear as a posible property and stays in white. It doesnt. I have to copy the code from the web to make it work.
you can define in scss this way,
for example,
body{
#media(min-width:801px){
margin: 0 auto;
margin-top: 40px;
margin-left: 370px;
}
}
This is the website, and more specifically, the page.
I'm currently working on a responsive theme, which has media queries, but something about the CSS modifications I've made, are preventing the menu (top right in gold), and the sidebar (this only exists on the blog page, but it is important... it's the box at the right of the content block) from merging with the header/title/left-hand content. It shows up on the ipad mini, the regular ipad 4, but it is okay in an android browser screen. You can observe the issue by resizing the browser.
#media only screen and (min-width:768px) {
.site-navigation .nav-menu {
display: block;
}
}#media only screen and (max-width:767px) {
.menu-toggle {
display: block;
}
}#media only screen and (min-width:768px) and (max-width:959px) {
.wrap {
max-width: 728px;
}
That is the media screen css. The respective divs are all positioned relatively. Does anyone have any advice on how to fix this problem? Any code tidbits?
The first thing I see is that this HTML is not closed:
<div id="header" onclick="location.href='http://camillagabrieli.com
That needs to be fixed first. Try adding outlines to your CSS:
* { outline: 1px dashed black }
I find that helps a lot when it comes to seeing what's actually wrong with the different floated elements. There are quite a few things wrong with your arrangement and your CSS. You don't need to relatively position all of these things.
To fix the main content section:
Add the following to #main:
overflow:hidden;
And make #content and #sidebar-primary like this:
#content {
float: left;
width: 75%;
margin-left: 40px;
margin-right: 10px;
margin-top: 10px;
min-height: 50px;
}
#sidebar-primary {
float: left;
width: 20%;
border-top: 1px solid #222;
border-bottom: 1px solid #222;
height: 50%;
}
I'm not sure why you had margin-top: -460px; in your code, but that was what was breaking it, as was the fact that #main wasn't actually containing #content and #sidebar-primary. The code still needs cleaning up, but this will fix it more immediately.
Does this help?
I just starting turning away of doing all things in and am playing with div and floats.
I have a homepage that need to have a two column in top and one beneath.
When the user have a small screen as a mobile, it need to put every box on each row as the example.
What is the correct way of doing this?
This show the code: http://jsfiddle.net/boje/cMF4P/1/
This is what the homepage do now.
Some of the code
/* ===== form2 ===== */
fieldset.fieldsetLeft {
width:47%;
float:left;
padding: 10px;
margin-bottom: 15px;
}
fieldset.fieldsetRight {
width: 45%;
float:right;
padding: 10px;
margin-bottom: 15px;
}
.clearBoth {
clear: both;
}
For smart phones & tablets you can make a dedicated css file which will overload the normal css style sheet:
In your header .html:
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="smart_tablet.css" type="text/css" />
Then into smart_tablet.css redefine the specific:
fieldset.fieldsetLeft {
width:100%;
float: none;
}
fieldset.fieldsetRight {
width: 100%;
float: none;
}
In your code you can change float right to float left on the right box and it will work as intended.
http://jsfiddle.net/PzAsJ/
fieldset.fieldsetRight {
width: 45%;
float:left;
padding: 10px;
margin-bottom: 15px;
}
However have a look at css3 media queries, it gives you much more possibillities.