I am trying to set 2 different width to #home-content-wrap. What I eventually want is to be able to set to home-content-wrap div 80% width if the screen size is smaller than 768px!
It is like:
1156 width:80%
<1156 width:100%
<768 width: 80%
Couple of notes:
But <768 width:80% doesn't wok!
If I remove >1156 condition then <768 works!
If you look the code carefully you ll see that <768 condition changes text color but not width...or not bg color too..
Here is my page/div style:
*{margin:0;padding:0;text-align:center;}
#wrap{width:100%;height:100%;}
#home-content-wrap{width:80%; max-width:1600px; height:auto; margin:50px auto;
border:1px solid blue;}
/**Responsive Columns**/
.home_lay_1_of_2 {
width: 49.5%;
margin-left:0.50%; background:lightblue;
}
.home_lay_1_of_3 {
width: 49.5%; background:grey;
}
here is breaking points:
/****breakpoint 1**/
#media only screen and (max-width: 768px) {
#home-content-wrap{width:80%; max-width:1600px; height:auto; margin:50px auto; color:
yellow; border:1px solid yellow;}
.home-txt{float:left; width:100%; height:500px; }
.home_lay_1_of_2 {
width: 100%;
margin-left:0;
}
.home_lay_1_of_3 {
width: 100%;
}
}
/***Breakpoint 2***/
#media only screen and (max-width: 1156px) {
#home-content-wrap{width:100%; max-width:1600px; height:auto; margin:50px auto;
border:1px solid black;}
}
here is my responsive settings:
.section {
clear: both;
padding: 0;
margin: 0;
}
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.col {
display: block;
float:left;
}
Here is the fiddle http://jsfiddle.net/GQgNx/
What's wrong here?
Change the second breakpoint media query to:
#media only screen and (min-width: 768px) and (max-width: 1156px) {
#home-content-wrap {
border: 1px solid black;
height: auto;
margin: 50px auto;
max-width: 1600px;
width: 100%;
}
}
Example: http://jsfiddle.net/GQgNx/2/
I have updated your fiddle with some cleaner code. It's just an issue of the way your media queries were setup.
Your outline should be something like this:
/** narrow code default **/
#media only screen and (min-width:768px) {
}
#media only screen and (min-width:768px) and (max-width:1156px) {
}
#media only screen and (min-width:1156px) {
}
Updated fiddle http://jsfiddle.net/GQgNx/5/
Related
I'm fairly new to the world of scripts and coding, so I do not know the best terms to use.
I am trying to make a somewhat simple website, and I want my header background to have padding-bottom 120px at min-width 600px, and 0 at 1050. However, the padding-bottom only updates when changed in the properties for header.
Here is my code:
header {
border-radius: 5px;
display: block;
width: auto;
min-height: 200px;
background: #E44;
padding-top: 40px;
padding-left: 38px;
padding-right: 38px;
padding-bottom: 136px;
}
#media screen and (min-width: 600px) {
.header {
padding-bottom:120px
}
}
#media screen and (min-width: 1050px) {
.header {
padding-bottom: 0px;
}
}
The padding-bottom stays at 136px no matter the min-width of the window.
Make sure that you know the difference the dot does. .header is selection the header class. While header selects the element. Your code works fine, as you can see here, I'm using the media queries to change the background color instead of padding, just to make the point clear.
Fiddle example
header {
border-radius: 5px;
display: block;
width: auto;
min-height: 200px;
background: #E44;
padding-top: 40px;
padding-left: 38px;
padding-right: 38px;
padding-bottom: 136px;
}
#media screen and (min-width: 600px) {
.header {
background-color: blue;
}
}
#media screen and (min-width: 1050px) {
.header {
background-color: green;
}
}
<header class="header">
</header>
There is a small typo here. You have an additional dot(.) which will mean a class selector as against the other style which is on element selector.
#media screen and (min-width: 600px) {
header {
padding-bottom:120px
}
}
#media screen and (min-width: 1050px) {
header {
padding-bottom: 0px;
}
}
I do have the viewport line in my code, btw. Below is my CSS - I suspect I've made an obvious error, but just am not seeing it! The text and images do flow into the expected one column, but the narrower divs remain narrow, the background image still shows, the images still full size. Please advise.
.cont { width:100%; max-width:1000px; position:relative; margin:0 auto; font-family:Arial, Helvetica, san serif; font-size:1em; text-align:left; }
.hdr { width:100%; max-width:1000px; position:relative; margin:0 auto; }
.row1 { width:100%; position:relative; background:url(https://myimagefiles.com/dinnerman/tbg.png); float:left; }
.row1l { width:26%; position:relative; margin-left:2em; float:left; }
.row1r { width:64%; position:relative; margin-left:2em; margin-right:2em; float:left; }
.row2 { width: 94%; position:relative; text-align:left; margin:0 auto; }
.row3l { float:left; width: 45%; position:relative; text-align:left; margin:0 0 0 2em; }
.row3r { float:left; width: 45%; position:relative; text-align:left; margin:0 0 0 2em; }
.grntxt { color:#207815; }
.bott { width:100%; height:19px; )
#media only screen and (max-width: 750px) {
.cont { width:100%; }
}
#media only screen and (max-width: 750px) {
.hdr { width:94%; }
}
#media only screen and (max-width: 750px) {
.mimg { width:94%; }
}
#media only screen and (max-width: 750px) {
.row1 { width:94%; margin-left:.2em; margin-right:.2em; background-image:none;}
}
#media only screen and (max-width: 750px) {
.row1l { width:94%; margin-left:.2em; margin-right:.2em; background-image:none;}
}
#media only screen and (max-width: 750px) {
.row1r { width:94%; margin-left:.2em; margin-right:.2em; background-image:none;}
}
#media only screen and (max-width: 750px) {
.row2 { width:94%; margin-left:.2em; margin-right:.2em; }
}
#media only screen and (max-width: 750px) {
.row3l { width:94%; margin:0 auto; }
}
#media only screen and (max-width: 750px) {
.row3r { width:94%; margin:0 auto; }
}
#media only screen and (max-width: 750px) {
.bott { display:none;}
}
You have a typo
.bott { width:100%; height:19px; )
Should terminate with a } not a )
.bott { width:100%; height:19px; }
You should use a CSS linter (such as CSSLint) to make sure you're not making any typos. They can be run as separate tools, as part of your build chain (Grunt, Gulp, Webpack, etc.) or directly in any proper IDE (Sublime, Atom, etc.). There's also online versions like this one which I used to track down the errors in your code. They're good for quick checks like this, but not suitable for a real development workflow.
Additionally, you should really group your media queries
#media only screen and (max-width: 750px) {
.cont { width:100%; }
.hdr { width:94%; }
.mimg { width:94%; }
...
}
There's no need to have separate ones for each set of styles you're applying.
So I have an element that I want to change at 750px and 500px:
.footer-logo img {
content:url(...);
}
and then:
#media only screen and (max-width: 700px) {
.footer-logo img{
margin-top: -58px !important;
padding:64px;
}
}
#media only screen and (max-width: 500px) {
.footer-logo img {
width: 80vw !important;
max-width:none !important;
margin-top:-10px !important;
}
The 500px changes happen but the changes when testing at 700px do not happen. I know I shouldn't be using !important so much but the styling just won't happen without it... Any help is appreciated
You can Try This. please check div Color changes According to media query
HTML
<div class="footer-logo">
<img src="http://dummyimage.com/100x50/000/fff&text=Throbble!">
</div>
CSS
#media only screen and (max-width: 700px) {
.footer-logo > img{
margin-top: -58px !important;
padding:64px;
}
.footer-logo {
background-color:yellow;
}
}
#media only screen and (max-width: 500px) {
.footer-logo > img {
width: 80px !important;
max-width:none !important;
margin-top:-10px !important;
}
.footer-logo {
background-color:red;
}
}
I'm trying to add mobile view for this page. I want article and div.sidebar.col-md-4 to be on left on mobile view (sidebar above article). Here's link to the page:https://ewelinawoloszyn.github.io/Press/#mm-0
Here's my code
#media (min-width: 992px){
div.sidebar.col-md-4 {
float: right !important;
width: 162px !important;
}
}
#media (min-width: 1200px){
div.sidebar.col-md-4 {
float: right !important;
width: 162px !important;
}
article{width:50% !important;
float:left !important;}
}
div.profile p{
text-align: justify;
}
div.profile p a{
float:right;
}
div.profile ul{
list-style: none;
padding-left: 0px;
}
h3.name{
margin-bottom: 30px !important;
}
article{
width: 50% !important;
float:left !important;}
#media (min-width: 992px)
.col-md-4 {
width: 33.3333%;
}
div.sidebar.col-md-4{
float:right;
width:162px;
}
div.profile img{
margin-bottom:20px;
}
img.arch{
width:120px !important;
height:100px !important;
margin-top: 18px !important;
float: left !important;
margin-right: 9px !important;
}
div#disqus_thread{
float:left;
width: 523px;
}
What happens when I add media query for 768px the article appears below left side menu which I don't want. How to add mobile view without resetting 1200px view?
Any advice much appreciated,
Kind regards
Neko
div.sidebar.col-md-4{
float:right;
width:162px;
}
Move this inside #media (min-width:768px), and just define another style for width <= 768px
I'm using these media queries in CSS to make my footer responsive.
I want to make the 3 columns (#footer-left, #footer-middle, #footer-right) automatically move under each other when the screen is made smaller.
what would be the best way of doing this? I have a fiddle here: jsfiddle
/* for 980px or less */
#media screen and (max-width: 980px) {
#footer-left {
width: 41%;
padding: 1% 4%;
}
#footer-middle {
width: 41%;
padding: 1% 4%;
margin: 0px 0px 5px 5px;
border-right:none;
}
#footer-right {
padding: 1% 4%;
}
#footer-bottom {
display:none;
}
}
/* for 800px or less */
#media screen and (max-width: 780px) {
#footer-left {
border-right:none;
}
#footer-middle {
margin-left: 0px;
border-right:none;
}
}
/* for 700px or less */
#media screen and (max-width: 700px) {
#footer-left {
border-right:none;
}
#footer-middle {
margin-left: 0px;
border-right:none;
}
}
/* for 480px or less */
#media screen and (max-width: 480px) {
#footer-right {
display: none;
}
}
Just make your #footer-left, #footer-middle, and #footer-right divs all be width:100% when you want them to stack, with float:none on each of them. Your width may need to be less than 100% if you keep padding on any of the divs (in your case, width would be 92%, since you've got it set up for 4% padding on left and right of each div).