I'm trying to insert a simple media query so that the submit form spans 90% width of the page when viewed on a phone (it's set to 50% at all other times). When I scale the viewport down, it doesn't pick up the media query. Here is my code:
scss:
#media(max-width:767px){
.submit{
width: 90%;
}
}
.submit{
width: 50%;
margin: auto;
margin-top: 300px;
margin-bottom: 300px;
.submitBackground{
background-color: $orange;
opacity: .6;
padding: 20px;
}
.submitEvent{
background-color: white;
opacity: .6;
button{
margin-top: 15px;
margin-bottom: 15px;
}
}
}
form{
width: 80%;
margin: auto;
text-align: center;
padding: 20px;
.form-control{
margin: 10px;
}
.radio-inline{
margin: 10px;
position: relative;
}
}
Your media query needs to be after the non-media query declaration. Otherwise it will not be able to override the property.
.submit {
...
}
#media (max-width:767px) {
.submit{
width: 90%;
}
}
Related
I made a Netflix clone and I was working on making it responsive. It was working fine and giving the desired output in VS Code but then I uploaded it to a live website to check if it is working then, but the responsiveness was no longer working as expected.
Below is the media queries code >>>>
#media screen and (max-width:768px) {
.logobtn img{
height: 30px;
}
img.dropdown{
height: 10px;
width: 15px;
}
.btn:nth-child(1){
margin-right: 10px;
}
.content{
/* padding: 0px; */
width: 330px;
margin-left: -20px;
}
.content h1{
font-size: 30px;
line-height: 37px;
padding: 0;
}
.content h3{
padding: 0;
width: 375px;
font-size: 24px;
}
.form{
flex-direction: column;
position: relative;
height: 40px;
}
.email{
margin-left: -155px;
/* margin-right: -100px; */
padding-right: 0px;
}
.submit{
position: absolute;top: 50px;
/* border-radius: 10px; */
}
.row{
flex-direction: column;
}
}
Im so new in CSS and trying to fix the following code..
I want a simple thing where the screen size is smaller than 400 change the image size..
it should work but it doesn't..
I tried to make
* {
box-sizing: border-box;
}
body, html {
background: #fff;
height: 100%;
margin: 10px;
}
.left__img2 {
position: absolute;
float: left;
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
border-radius: 20px;
width: 600px;
height: 400px;
}
#media screen and (max-width: 500px) {
.left__img2 {
width: 10px;
}
}
Media queries at the top of the CSS need !important to over rule the media query. Media queries at the bottom do not need !important. I placed the query at the top so I used !important to over rule any other style after.
#media screen and (max-width: 500px) {
.left__img2 {
width: 10px !important;
}
}
* {
box-sizing: border-box;
}
body, html {
background: #fff;
height: 100%;
margin: 10px;
}
.left__img2 {
position: absolute;
float: left;
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
border-radius: 20px;
width: 600px;
height: 400px;
}
I think this will work.
#media screen and (max-width: 500px) {
.left__img2 {
max-width: 10px;
}
}
Your code works well in the following example (resize your window), maybe it comes from a side effect of the rest of your code, can you show us the rest of your code?
.left__img2 {
position: absolute;
float: left;
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
border-radius: 20px;
width: 600px;
height: 400px;
background-color: red;
}
#media screen and (max-width: 500px) {
.left__img2 {
width: 10px;
background-color: yellow;
}
<div class="left__img2"><div>
I want to resize column width using media queries but i can't able to so i need expert advice and i can show you whole code if you want.The problem is occuring in my .cities class and .cities .col, i can't change width,font-size,icon size.
Nothing at all.
Thank You
CSS code:
#media only screen and (max-width:767) and (orientation:landscape) {
/* Styles for Landscape screen */
header {
height: 200vh;
}
header nav li a {
font-size: 85%;
}
.cities .col {
display: block;
width: 100%;
}
.cities h3 {
font-size: 10%;
}
.ios-small {
font-size: 100%;
}
.cities .col img {
width: 100%
}
.cities {
padding: 0px;
}
.cities .col {
margin-top: 5%;
padding-bottom: 2%;
width: 100%;
transition: width 0.3s;
}
.cities .col:hover {
background: rgba(234, 234, 234, 0.9);
color: black;
}
.cities .col img {
width: 100%;
height: auto;
margin: 0 0 0 0px;
}
.cities h3 {
text-align: left;
margin: -4px 0 0 0px;
font-size: 100%;
}
.ios-small {
font-size: 20%;
font-weight: 200;
margin-right: 5px;
font-style: italic;
color: #e67e22;
}
}
This is the Preview of Website in Iphone6 Landscape
You need to add a unit for your breakpoint so max-width:767px.
My site, like many others, utilizes bootstrap's carousel on the home page.
For some reason, despite the carousel-control appearing and everything else looking fine, the data slide functionality stops working on monitor sizes less than 480px (so, any mobile device).
Is there a snippet of code I need to add to the #media(max-width:480px) section in the CSS? As it stands I don't have any carousel/responsive related code under that size, but just the following:
#media (max-width: 979px) {
.carousel .item {
height: 500px;
}
.carousel img {
width: auto;
height: 500px;
}
}
#media (max-width: 767px) {
.carousel {
margin-left: -20px;
margin-right: -20px;
}
.carousel .container {}
.carousel .item {
height: 300px;
}
.carousel img {
height: 300px;
}
.carousel-caption {
width: 65%;
padding: 0 70px;
margin-top: 100px;
}
.carousel-caption h1 {
font-size: 30px;
}
.carousel-caption .lead, .carousel-caption .btn {
font-size: 18px;
}
}
An example can be seen here.
Add a z-index on you carousel-control:
.carousel-control {
height: 80px;
margin-top: 0;
font-size: 120px;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
background-color: transparent;
border: 0;
position: absolute;
top: 40%;
left: 15px;
color: #fff;
z-index: 99999; /*Add This */
}
What this is doing it just making this control be in front of the slider that is more than the actual screen size.
SOLVED: Tom: You were so right. Unfortunately WordPress function wp_head() was adding the width=1100 because of a plugin. Thanks!
I'm working on a new responsive website, but can't seem to get the #media query to work.
It does work when resizing the browser window on my desktop, but it won't work on my ipad, iphone or android phone.
What am I doing wrong?!
Here the link: http://demo.mindspins.com/atmnieuw/
Here's the link to the CSS: http://demo.mindspins.com/atmnieuw/wp-content/themes/atm/css/dynamic.php
Thanks in advance!
On request the CSS code:
#media all and (max-width: 1460px) {
.site-width{ width: 1199px; }
.main-width{ width: 719px; }
}
#media all and (max-width: 1220px) {
.site-width{ width: 959px; }
.main-width{ width: 479px; }
#page-title h1.thetitle{
font-size: 20px;
line-height: 24px;
}
.sidebar .widget a.form-button-link, .sidebar .widget span.form-button-link{
font-size: 20px;
line-height: 24px;
}
}
#media all and (max-width: 980px) {
.site-width{ width: 719px; }
.main-width{ width: 479px; }
.right-width{ display: none; }
#header-right{ display: none; }
.widgets-wrapper-1{ display: block; }
.widgets-wrapper-3{ display: block; position: relative; padding: 20px 0 0 20px; }
}
#media all and (max-width: 740px) {
.site-width{ width: 95%; margin: 0 auto;}
#header-wrapper{ width: 100%; }
#header-left{ display: none; }
#header-mid{ height: 80px; }
#atmlogo a.atm {
z-index: 100;
top: 24px;
left: 0;
}
.main-width{ width: 100%; }
.left-width{ width: 100%; }
.sidebar-left{ display: none; }
.site-bg{ display: none; }
#header-left span.header-contact{ height: 80px; width: 100%;}
#main-nav{ height:auto !important; }
#mobile-nav{
margin: -4px 0 1px 0;
display: block;
position: relative;
width: 100%;
}
#mobile-nav .nav-wrapper{
display: block;
color: #fff;
background: #cc0033;
margin: 1px 0;
height: 40px;
padding: 0 10px;
}
#mobile-nav .nav-wrapper select.atm-dropdown{
font-size: 12px;
display: block;
height: 40px;
width: 100%;
color: #fff;
background: #cc0033;
border: 0;
clear: both;
-webkit-border-radius: 0;
-webkit-appearance: none;
}
#mobile-nav .theme-s{
width: 100%;
background: #cc0033;
color: #fff;
}
#mobile-nav input.s{
background: #cc0033;
color: #fff;
}
#mobile-nav input.searchsubmit{
border-left: solid 1px #dcdcdc;
color: #fff;
background: #cc0033;
background-image: url(../images/icon_search.png);
background-repeat: no-repeat;
background-position: right top;
-webkit-border-radius: 0;
-webkit-appearance: none;
}
#primary{ display: none; }
#main-content-header{
height:auto !important;
margin: 0 0 1px 0;
}
#main-content-header span.header-image{
display: block;
float: left;
width: 25%;
height:auto !important;
margin: 0;
}
#main-content-header span.header-image img{
line-height: 0px;
margin: 0;
padding: 0;
}
#page-title{
height: 79px;
}
}
#media all and (max-width: 500px) {
body {
font-size: 12px;
line-height: 20px;
}
#footer-nav{ display: none; }
#copyrights{ display: none; }
.entry-content-bg{ padding: 20px; }
#page-title .title-wrapper{ padding: 0 20px }
#page-title h1.thetitle{
font-size: 16px;
line-height: 20px;
}
}
You can use this code in the head tag:
<meta name="viewport" content="width=device-width, initial-scale=1"/>
On looking again, when using my iPhone 4S and the Remote Web Inspector introduced in iOS 6, I couldn't find any styles for anything below max-width: 1200px, even though they are in the CSS file. I don't know why this is.
Also, I wrote a blog post about Responsive design and Media Queries a few months, you can read it here if you wish. Not saying you're not good at media queries (it's a very nice site!) just hope it will be an interesting read for you :)
EDIT: just looking at your site again, I noticed in the head (right at the bottom) you have this code:
meta name="viewport" content="width=1100"
This could be why the styles weren't applying at anything below a screen width of 1100px or 1200px. Take this out and try it again.
It might have something to do with having your CSS in seperate files. As a general rule you should always write all your CSS in one file (style.css). It shouldn't do but just for clarity put them both in the same file and see what happens. If it doesn't work comment on this and I'll take another look.