I have a grid with 8 images. Width wise I've made them pretty responsive.
.gallery .item {
width: 33%;
height: 368px;
float: left;
}
#media screen and (max-width: 1650px) {
.main-content {
width: 55.66666667%;
}
.gallery .item {
width: 33%;
height: 330px;
}
}
#media screen and (max-width: 1540px) {
.gallery .item {
width: 33%;
height: 290px;
}
}
#media screen and (max-width: 1450px) {
.main-content {
width: 50.66666667%;
}
.gallery .item {
width: 33%;
height: 250px;
}
}
#media screen and (max-width: 1315px) {
.main-content {
width: 45.66666667%;
}
.gallery .item {
width: 33%;
height: 210px;
}
}
#media screen and (max-width: 1200px) {
.main-content {
width: 75%;
}
.gallery .item {
width: 33%;
height: 260px;
}
}
#media screen and (max-width: 1000px) {
.main-content {
width: 100%;
position: relative;
}
.gallery .item {
width: 33%;
height: 290px;
}
}
#media screen and (max-width: 830px) {
.gallery .item {
width: 33%;
height: 250px;
}
}
#media screen and (max-width: 650px) {
.gallery .item {
width: 33%;
height: 180px;
}
}
#media screen and (max-width: 650px) {
.gallery .item {
width: 33%;
height: 180px;
}
}
#media screen and (max-width: 560px) {
.gallery .item {
width: 33%;
height: 175px;
}
}
#media screen and (max-width: 500px) {
.gallery .item {
width: 100%;
height: 410px;
}
}
#media screen and (max-width: 380px) {
.gallery .item {
width: 100%;
height: 350px;
}
}
But when the theme is zoomed out, it doesn't look so great. In my case I require it to look at-least OK.
http://screencast.com/t/GlYN75pU
Here is a preview of the site.This is an actual preview, not a screenshot:
https://dl.dropboxusercontent.com/u/54191672/theme/index.html
How can I fix the images from being squashed when zooming out?
You're constraining width and height, that distorts the images aspect ratio as the width changes but the height does not.
In order to maintain the correct aspect ratio you must only constrain one of those parameters. Most developers constrain width because devices have a physical maximum viewing width, but can have an infinite vertical viewing height through scrolling.
For example:
#media screen and (max-width: 1650px) {
.main-content {
width: 55.66666667%;
}
.gallery .item {
width: 33%;
/* or height: auto; */
height: 100%;
}
}
Related
Why does the width of my site stretch to the edges of the browser in Internet Explorer? What am I missing?
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%; }
.site-main {
padding: 10vw 10vw 5vw;
max-width: 1110px; }
#media (min-width: 1440px) {
.site-main {
padding: 154px 154px 77px;
margin-left: auto;
margin-right: auto; } }
#media (max-width: 760px) {
.site-main {
padding: 5vw 5vw 5vw; }
}
I believe this code covers the relevant parts.
#jeremy, please check the below working example in your browser(based on your css, with some minor modifications) and see if that issue still exists.
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.site-main {
padding: 10vw 10vw 5vw;
max-width: 1110px;
margin-left: auto;
margin-right: auto;
}
#media (min-width: 1440px) {
.site-main {
padding: 154px 154px 77px;
}
}
#media (max-width: 760px) {
.site-main {
padding: 5vw 5vw 5vw;
}
}
<div class="site-main" style="background: #eee"> </div>
Padding just puts space around the content, but not around the edges of the div with your site-main class.
Here is a fiddle with your code, changed padding to margin, and some color added to show the difference:
https://jsfiddle.net/qxp098j3/4/
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.site-main {
margin: 10vw 10vw 5vw;
max-width: 1110px;
background-color:Blue;
}
#media (min-width: 1440px) {
.site-main {
margin: 154px 154px 77px;
}
}
#media (max-width: 760px) {
.site-main {
margin: 5vw 5vw 5vw;
}
}
<body>
<div class="site-main">
blah blah blah
</div>
</body>
ERRORS
#media only screen (min-width: 1021px) and (max-width: 1180px) {
.twee img {
margin-top: 3em;
}
.drie {
margin-top: 3em;
}
.audiovisual iframe {
width: 90%;
}
.cp img {
width: 75%;
height: 75%;
display: inline;
padding: 0;
}
}
#media only screen (min-width: 791px) and (max-width: 1020px) {
body {
background-image: url(IMG/Sam-open-copy-1020.jpg);
}
.twee img {
margin-top: 7em;
}
.drie {
margin-top: 7em;
}
.zes {
margin-top: 2em;
}
.audiovisual iframe {
width: 90%;
}
.kaart iframe {
width: 75%;
height: 75%;
padding: 0;
margin: 0;
padding-bottom: 2em;
}
.cp img {
width: 75%;
height: 75%;
display: inline;
padding: 0;
}
#totop {
right: 0;
}
}
So this is my code, my mediaqueries won't apply on my HTML.
When I validate I got these errors.(see the image ERRORS) But I can't find out what's wrong with it? I checked everything but probably I can't find it because I look over it or something....
Add an extra 'and' in your #media query:
#media only screen and (min-width: 1021px) and (max-width: 1180px) { ...
i want to implement following styles for 900 to 1023px
.navbar-brand {
float: left;
margin-right: 5px;
margin-left: -15px
}
.navbar-nav {
float: left;
margin-top: 0;
margin-bottom: 0
}
.navbar-nav>li {
float: left
}
.navbar-nav>li>a {
border-radius: 0
}
.navbar-nav.pull-right {
float: right;
width: auto;
margin:10px 0 ;
}
.navbar-toggle {
position: relative;
top: auto;
left: auto;
display: none
}
.nav-collapse.collapse {
display: block!important;
height: auto!important;
overflow: visible!important
}
i applied following media query
#media screen (min-width: 900px) and (max-width: 1024px) {
// here goes above code
}
but problem is that these stlyes are being applied on 1300 + resolution as well . whats wrong with it please help
You miss and after #media screen
#media screen and (min-width: 900px) and (max-width: 1024px) {
// here goes above code
}
I'm using Prepros to compile my SCSS files to CSS, but it gives me an error when i try to use media queries. I tried Coala and Scout as well.
If i just copy this code into output CSS it works.
What am i doing wrong?
#media only screen and (max-width: 320px) {
body {
width: 320px;
}
.wrapper {
width: 320px;
margin: 0 auto;
}
.works-wrap {
width: 320px;
}
}
#media only screen and (min-width: 320px) and (max-width: 610px) {
.wrapper {
width: 320px;
margin: 0 auto;
}
.works-wrap {
width: 320px;
}
}
#media only screen and (min-width: 610px) and (max-width: 950px) {
.wrapper {
width: 650px;
margin: 4% auto;
}
.name {
width: 100%;
}
.works-wrap {
width: 650px;
margin-left: 10px;
}
}
#media only screen and (min-width: 950px) and (max-width: 1024px) {
.wrapper {
width: 950px;
margin: 4% auto;
}
.name {
width: 100%;
}
.works-wrap {
width: 950px;
}
}
Error code:
Error: Invalid CSS after "": expected selector, was "#media only scr..."
on line 169 of style.scss
164: width: 650px;
165: margin-left: 10px;
166: }
167: }
168:
169: #media only screen and (min-width: 950px) and (max-width: 1024px) {
170: .wrapper {
171: width: 950px;
172: margin: 4% auto;
173: }
174: .name {
Backtrace:
style.scss:169
c:/Program Files (x86)/Prepros/resources/app/ruby/ruby_gems/gems/sass-3.4.9/lib/sass/scss/parser.rb:1165:in `expected'
Try this it is a copy/paste mistake
#media only screen and (max-width: 320px) {
body {
width: 320px;
}
.wrapper {
width: 320px;
margin: 0 auto;
}
.works-wrap {
width: 320px;
}
}
#media only screen and (min-width: 320px) and (max-width: 610px) {
.wrapper {
width: 320px;
margin: 0 auto;
}
.works-wrap {
width: 320px;
}
}
#media only screen and (min-width: 610px) and (max-width: 950px) {
.wrapper {
width: 650px;
margin: 4% auto;
}
.name {
width: 100%;
}
.works-wrap {
width: 650px;
margin-left: 10px;
}
}
#media only screen and (min-width: 950px) and (max-width: 1024px) {
.wrapper {
width: 950px;
margin: 4% auto;
}
.name {
width: 100%;
}
.works-wrap {
width: 950px;
}
}
There is a hidden char just after the closing bracket of #media only screen and (min-width: 610px) and (max-width: 950px) just delete it
I'd like to make my gallery http://wordpress.org/extend/plugins/photospace-responsive/ be responsive with a vertical layout changing into a horizontal one when the browser is scaled down for mobile.
Please can you tell me how I can make it revert when the screen size is smaller to the gallery being on top?
See my test page
http://brightmist.co.uk/gallery/
I've even tried media queries
.photospace_res .gal_content {
float: left;
width: 80%;
}
.photospace_res .thumbs_wrap2 {
float: left;
min-height: 800px;
width: 20%;
}
#media all and (max-device-width: 480px) {
.photospace_res .gal_content {
float: none;
width: 100%;
}
.photospace_res .thumbs_wrap2 {
float: none;
min-height: 0;
width: 100%;
}
}
Thanks for your help
Judi
Yay I fixed it and added a few extra styles
.photospace_res .gal_content {
float: left;
width: 80%;
}
.photospace_res .thumbs_wrap2 {
float: left;
width: 20%;
}
.photospace_res {
margin: 0;
}
.photospace_res .ss-controls {
border: 1px solid #CCCCCC;
margin-bottom: 20px;
padding: 5px 10px;
}
#media screen and (max-width: 700px) {
.photospace_res .gal_content {
float: none;
width: 100%;
}
.photospace_res .thumbs_wrap2 {
float: none;
min-height: 0;
width: 100%;
}
}