Hi am using 2 media queries and they don't appear to work when viewed on tablet or phone, the original css still appears to override. i would like 2 blocks one under the other for tablet and phone view rather than the inline side by side on desktop view
original
.site-logo {
float:left;
display:inline-block;
width: 60%;
vertical-align: top;
}
img.logo {
height:auto;
width:auto;
}
.header-search {
float:right;
display:inline-block;
width: 40%;
vertical-align: top;
margin-top:2%;
}
media
/* Tablet */
#media only screen and (min-width: 768px) {
.site-logo {
display:block;
width: 100%;
margin: 0 auto;
}
img.logo
{
height:auto;
width:auto;
margin: 0 auto;
}
.header-search
{
display:block;
width: 100%;
margin: 0 auto;
}
}
/* Mobile */
#media only screen and (min-device-width: 480px) {
.site-logo
{
display:block;
width: 100%;
margin: 0 auto;
}
img.logo
{
height:auto;
width:auto;
margin: 0 auto;
}
.header-search {
display:block;
width: 100%;
margin: 0 auto;
}
}
link to site: Photohunters
Thank you
Melanie
Update
Have tried again but no go!
.site-logo {
float:left;
display:inline-block;
width: 60%;
vertical-align: top;
}
img.logo {
height:auto;
width:auto;
}
.header-search {
float:right;
display:inline-block;
width: 40%;
vertical-align: top;
margin-top:2%;
}
/* Tablet */
#media only screen and (min-width: 720px) and (max-width: 800px) {
}
/* Mobile */
#media only screen and (min-width: 480px) and (max-width: 719px) {
#sidebar { display:none; }
#sidebar-profile { display:none; }
#site-content-left {
width: 95%;
margin:0 auto;
}
.site-logo {
display:block;
width: 100%;
margin: 0 auto;
}
img.logo
{
height:auto;
width:auto;
margin: 0 auto;
}
.header-search {
display:block;
width: 100%;
margin: 0 auto;
}
}
/* Mobile - 320px */
#media only screen and (min-width: 300px) and (max-width: 479px) {
#sidebar {display:none;}
#sidebar-profile {display:none;}
#site-content-left {
width: 95%;
margin:0 auto;
}
.site-logo
{
display:block;
width: 100%;
margin: 0 auto;
}
img.logo
{
height:auto; width:auto; margin: 0 auto;
}
.header-search
{
display:block;
width: 100%;
margin: 0 auto;
}
}
html as requested
`<meta name="viewport" content="width=device-width" />
<div id="wrap">
<div class="site-logo"> <img class="logo" src="<?php echo get_stylesheet_directory_uri(); ? >/images/logobestnewstreight300.png" alt="photohunters.org" /></div>
<div class="header-search">
<?php if (is_page('home')) { ?>
<div class="fb-share-button" data-layout="button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href=" <?php echo get_permalink(); ?>" layout="button_count" show_faces="false" ></fb:like></div><?php } ?>
<div class="headersearchbox">
<?php $results_page = site_url().'/search-results/'; ?>
<form name="search" method="post" action="<?php echo $results_page; ?>">
`
Related
I have had this problem for a while. Everything I have done to make my images responsive and contain in the parent element fails. My images get cutoff, they do not center, and zoom to smaller screens. Also, my homepage has a left margin space I can't seem to fix. I would like my content centered, and zoomed properly on small screens. My full sized background image is also not filling the whole background on smaller screens. Any help would be appreciated.
<script src="jquery/jquery-3.0.0.min.js"></script>
<script>
$(document).ready(function() {
$('span.nav-btn').on('click', function(){
$('#menu').toggle();
})
$(window).resize(function(){
if ( $(window).width() > 768 ) {
$('#navigation.showing').removeAttr('nav-btn');
}
});
});//end ready
</script>
</head>
<body>
<div class="bg">
<div id="container" class="homepage">
<div id="header">
<p align="center"><img src="images/headerlogo.png" alt="Lost Tourist Logo"
width="517" height="269"/> </p>
</div>
<div id="navigation">
<span class="nav-btn"></span>
<ul id="menu" class="showing">
<li> <a href="index.html"><img src="images/menubar.png" alt="menu bar icon"
width="122" height="118"/></a>
<p align="center">Home</p></li>
<li><a href="beers.html"> <img src="images/menubar.png" alt="menu bar icon"
width="122" height="118"/></a>
<p align="center">The Brews</p></li>
<li><a href="events.html"> <img src="images/menubar.png" alt="menu bar icon"
width="122" height="118"/></a>
<p align="center">Events</p></li>
<li> <a href="crew.html"><img src="images/Crew.png" alt="crew" width="122"
height="118"/></a>
<p align="center">Crew</p></li>
<li> <a href="contact.html"><img src="images/Payphone_menubar.png"
alt="contact" width="122" height="118"/></a>
<p align="center">Contact</p></li>
</ul>
</div>
</div>
</div>
</body>
</html>
My CSS:
#charset "utf-8";
body, html {
height: 100%;
margin: 0;
}
.bg {
background-image:url(images/CityScape.jpg);
height:100%;
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
#container {
height: 900px;
width: 900px;
position: relative;
padding-bottom: 0px;
margin-top: auto;
margin-right: auto;
margin-bottom: 25px;
margin-left: auto;
}
#navigation ul li {
margin: 25px;
position: relative;
list-style-type: none;
float: left;
overflow: hidden;
}
#navigation ul li p {
font-family: Arial, Helvetica, sans-serif;
font-size: large;
font-weight: bold;
color: #000;
margin: 5px;
}
#content {
position: relative;
overflow: hidden;
clear: both;
width: 900px;
height: auto;
background-color: #09F;
border: thin solid #000;
padding-bottom: 0px;
margin-bottom: 25px;
}
#content table {
background-repeat: repeat;
background-color: #06F;
width:550px;
}
#content table p {
text-align: inherit;
display: table-row;
vertical-align: middle;
}
#content img {
position: relative;
}
#content h1 {
padding: 5px;
}
#navigation {
clear: both;
height: auto;
width: auto;
margin: 0px;
}
#content p {
font-family: Arial, Helvetica, sans-serif;
font-size: large;
margin: 5px;
}
#footer p {
margin: 5px;
}
#footer {
font-family: Arial, Helvetica, sans-serif;
font-size: large;
font-weight: bold;
clear: both;
margin-bottom: 25px;
margin-top: 15px;
border: thin solid #000;
background-color: #09F;
}
#header img {
padding: 25px;
}
My CSS for small screens:
/*smart phones*/
/* ----------- iPhone 6 ----------- */
/* Portrait and Landscape */
and (min-device-width: 375px)
and (max-device-width: 667px)
and (-webkit-min-device-pixel-ratio: 2) {
}
/* ----------- iPhone 6+ ----------- */
/* Portrait and Landscape */
and (min-device-width: 414px)
and (max-device-width: 736px)
and (-webkit-min-device-pixel-ratio: 3) {
}
/* ----------- Galaxy S5 ----------- */
/* Portrait and Landscape */
and (device-width: 360px)
and (device-height: 640px)
and (-webkit-device-pixel-ratio: 3) {
}
body, html {
height: 100%;
marging 0;
}
.bg {
background-image:url(images/CityScape.jpg);
height:100%;
width:100%;
background-repeat:no-repeat;
background-size:cover;
min-width:100%;
}
#container {
width: 100%;
height: 100%;
margin: auto;
padding:5px;
margin:0px;
}
#header img {
position: relative;
height: auto;
max-width: 100%;
max-height:100%;
overflow: hidden;
}
#navigation {
font-size:large;
height: auto;
width:100%;
float:none;
overflow:hidden;
margin:auto;
padding:10px;
}
#navigation ul {
padding: 0;
text-align:center;
}
#menu {
float:none;
margin:auto;
display:none;
width:100%;
max-width:360px;
position:relative;
list-style-type:none;
padding:0;
text-align:center;
}
.nav-btn {
width:100%;
background-color:#09F;
text-align:center;
box-sizing:border-box;
padding:15px 10px;
font-weight:bold;
font-size:large;
text-align:center;
cursor:pointer;
display:block;
height:100%;
}
.nav-btn:after {
content:url(images/mobilemenu.png);
}
#menu li {
width:100%;
font-size:large;
font-weight:bold;
background-color:#09F;
display:inline-block;
margin:0px;
border:#000 medium solid;
float:none;
overflow:hidden;
text-align:center;
vertical-align:top;
}
#menu img {
margin:0px;
padding:0px;
width:90px;
height:90px;
position:relative;
}
#navigation ul li {
margin: 0px;
width: 100%;
position: relative;
float: none;
overflow: hidden;
}
#menu li a {
width:100%;
display:block;
}
#content {
width:100%;
height:100%;
margin:auto;
padding:10px;
}
#content background img {
max-height:100%;
max-width:100%;
}
.socialmedia {
width:30px;
height:30px;
max-width:30px;
max-height:30px;
}
.bigfoot {
width:50px;
height:50px;
max-width:200px;
max-height:200px;
}
.mail {
max-height:110px;
max-width:110px;
}
#content img {
height:auto;
width:100%;
position:relative;
overflow:hidden;
margin:5px;
}
#content table, tbody, th, td, tr {
display:block;
width:100%;
height:auto;
min-height:100%;
min-width:100%;
}
#content table {
border-collapse: collapse;
width:auto
height: auto;
padding: 10px;
position: relative;
min-width:100%;
}
#content td {
min-width:100%;
min-height:100%;
display:inline-block;
margin:5px;
padding:5px;
position:relative;
width:auto;
}
#content table p {
display:block;
text-align:inherit;
vertical-align:middle;
max-width:100%;
}
#footer {
width:100%;
height:100%;
}
first, add a basic box-sizing property
*{box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;}
2) remove margin from #container
3) remove margin from body
4)for responcive img use img{max-width: 100%;height: auto;}
How can I set an image as header which is responsive?
I've tried already the Bootstrap's img-responsive class, but the height is to large on small screens.
I've tried this, but the image has each time the original size:
#media (max-height: 700px){
.img-theme {
display: block;
width:auto;
max-width:100%;
height:250px;
}
}
/* sm */
#media (min-height: 701) {
.img-theme {
display: block;
width:auto;
max-width:100%;
height:275px;
}
}
/* md */
#media (min-height: 999px) {
.img-theme {
display: block;
width:auto;
max-width:100%;
height:400px;
}
}
/* lg */
#media (min-height: 1200px) {
.img-theme {
display: block;
width: auto;
max-width:100%;
height:500px;
}
}
Try this:
.img-theme{
width: 100%;
height: auto;
max-heigth: 500px !important;
}
This should auto-resize height based on width, 100% make the image responsive of device screen width. And your image won't be taller than 500 pixels.
Here is an example:
body{
margin: 0;
}
.img-theme{
width: 100%;
height: auto;
max-height: 500px !important;
}
<img class="img-theme" src="http://cdn.wonderfulengineering.com/wp-content/uploads/2016/01/nature-wallpapers-5.jpg">
You don't need to use media-queries... just place it in your global css file.
Don't Use Width:auto width always 100%; in any resolution now its working fine check it once
#media (max-height: 700px){
.img-theme {
display: block;
width:100%;
height:250px;
}
}
/* sm */
#media (min-height: 701) {
.img-theme {
display: block;
width:100%;
height:275px;
}
}
/* md */
#media (min-height: 999px) {
.img-theme {
display: block;
width:100%;
height:400px;
}
}
/* lg */
#media (min-height: 1200px) {
.img-theme {
display: block;
width: 100%;
height:500px;
}
}
<img src="http://cdn.wonderfulengineering.com/wp-content/uploads/2016/01/nature-wallpapers-5.jpg" class="img-theme"/>
I have the following media screen queries which work on local browser as xml, but it does not seem to work in blogspot:
/* for 1024px or less */
#media screen and (max-width: 1024px){
#wrapper {
width:100%;
float:none;
}
#header-wrapper {
width:100%;
}
#navigation {
width:100%;
font-size:0.7em;
}
#content-wrapper{
width:63.8%;
float:left;
}
#sidebar-wrapper{
margin-left:0.5%;
width:34%;
float:left;
}
#footer-wrapper{
width:100%;
float:left;
}
}
/* for 700px or less */
#media screen and (max-width: 700px) {
#content-wrapper {
width: auto;
float: none;
}
#sidebar-wrapper {
width: auto;
float: none;
}
}
These work on local browser (firefox), but when I implemented them on blogger, the media queries won't work when I tried to change the width of the browser by zooming it out.
I had added the meta viewport code as well, but still not work.
<meta content='width=device-width,initial-scale=1.0,minimum-scale=0.5,maximum-scale=2.0' name='viewport'/>
Any ideas? great thanks!
*Addition:
This code also resulted broken view:
#navigation{
background-color: #5F5F5F;
margin-top: -25px;
}
#navigation ul{
margin-left:-40px;
}
#navigation ul li{
display:inline-block;
padding-right: 10px;
padding-top:10px;
padding-bottom:10px;
}
#navigation ul li:hover{
background-color:#000000;
}
#navigation ul li a{
text-decoration:none;
color:white;
font-family:calibri;
padding-left:10px;
}
Check this link : http://www.fiveforblogger.com/2012/01/fun-with-css-media-queries-in-blogger.html
<meta content='width=device-width, minimum-scale=1.0, maximum-scale=1.0' name='viewport'/>
...
#media only screen and (min-width: 768px) and (max-width: 1023px), only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
#page-wrapper
{ width: 800px; }
#side-wrapper
{ position: relative; float: left; top: 0px; margin-top: 20px; width: auto; }
...
...
}
#media only screen and (min-width: 500px) and (max-width: 767px) {
#page-wrapper
{ width: 640px; }
.menu, #logo img
{ width: 100%; }
...
...
}
Looks like the problem is the comment tag . Maybe blogger doesn't support this comment writing style. Now the problem is solved since I got rid of them!
I have a grid of thumbnails:
.thumbnail-container {
border: 1px solid red;
float: left;
width: 25%; (depending on screen size)
}
.thumbnail {
display: block;
height: auto;
width: 200px;
margin: 0 auto;
padding: 0px;
}
you get the idea...
Sometimes there are 5 thumbs, sometimes 4, 3, 2... in the same row depending on the #media device screen width.
So as you can see in the picture, my problem is the horizontal spacing between the thumbnails. Since the width of each thumb-container is equal (25% in the picture) and thumbnails are centered, there is double spacing betwet 1st and 2nd, 2nd-3d, 3rd-4th. On the contrary, the 1st thumb has half of that space to the left, and the 4th has it to the right:
It's like this: 1(A)2(B)2(C)2(D)1
And I want it like this: 1(A)1(B)1(C)1(D)1
Any ideas of how to make the spacing the same?
Many thanks!
I made this responsive grid that does what you need using CSS.
It uses media queries and nth-child().
The horizontal and vertical margins are equal.
FIDDLE
It shows you can use calculation to position grid elements with equal margins between each other. The margin between elements and window is also the same.
Code for screens wider than 751px isn't written yet though but you get the idea. Here is the code :
HTML :
<div id="container">
<div class="wrap">
<div class="foto">1</div>
</div>
<div class="wrap">
<div class="foto">2</div>
</div>
<div class="wrap">
<div class="foto">3</div>
</div>
... And so on ...
</div>
CSS :
html, body {
margin:0;
padding:0;
min-width:150px;
}
.wrap {
float:left;
position:relative;
}
.foto {
width: 150px;
height: 150px;
background: gold;
position:absolute;
}
#warning{display:none;}
#media screen and (min-width: 631px) {
.wrap {
width:20%;
padding-bottom:25%;
}
.wrap:nth-child(4n+2), .wrap:nth-child(4n+3){
}
.wrap .foto {
top:-75px;
margin-top:100%;
right:-30px;
}
.wrap:nth-child(4n+2){
margin:0 5% 0 7.5%;
}
.wrap:nth-child(4n+3){
margin-right:7.5%;
}
.wrap:nth-child(4n+2) .foto{
left:50%;
margin-left:-75px;
}
.wrap:nth-child(4n+3) .foto{
right:50%;
margin-right:-75px;
}
.wrap:nth-child(4n) .foto{
left:-30px;
}
#container{
margin-top:-45px;
}
}
#media screen and (min-width: 481px) and (max-width: 631px) {
.wrap {
width:25%;
padding-bottom:33.3%;
}
.wrap:nth-child(3n+2){
margin:0 12.5%;
}
.wrap .foto {
top:-75px;
margin-top:100%;
right:-37px;
}
.wrap:nth-child(3n+2) .foto{
left:50%;
margin-left:-75px;
}
.wrap:nth-child(3n) .foto{
left:-37px;
}
#container{
margin-top:-37px;
}
}
#media screen and (min-width: 331px) and (max-width: 480px) {
.wrap {
width:33.3%;
padding-bottom:50%;
clear:left;
}
.wrap:nth-child(even) {
float:right;
clear:right;
}
.wrap .foto {
top:-75px;
margin-top:100%;
right:-50px;
}
.wrap:nth-child(even) .foto {
left:-50px;
}
.wrap:nth-child(4n+3) .foto, .wrap:nth-child(4n+4) .foto {
bottom:-75px;
margin-bottom:100%;
}
#container{
margin-top:-25px;
}
}
#media screen and (max-width: 330px) {
.wrap {
width:50%;
padding-bottom:100%;
clear:left;
}
.wrap:nth-child(odd) .foto {
right:-75px;
bottom:0;
bottom:-75px;
margin-bottom:100%;
}
.wrap:nth-child(even) .foto {
top:0px;
right:-75px;
top:-75px;
margin-top:100%;
}
}
#media screen and (min-width: 751px) {
#warning{
color:#fff;
display:block;
position:fixed;
width:100%;
height:50%;
top:25%;
left:0;
background:#000;
text-align:center;
font-size:30px;
}
See my site here: http://www.element17.com. It may be desirable to change to a different album than the default in order to have more thumbnails available. The Paris album has the most images in it.
If you click the "Show Photo Grid" button in the very bottom-right, you'll see the photo/thumbnail grid I've contrived.
Right now it scales with the viewport, and I'd like it to continue to do so, but instead of smoothly increasing in size with the viewport I'd like it to only be as wide as the number of thumbnails that currently fit in the viewport, so that there's no empty whitespace to the right of the number of displayed thumbnails. I'd like it to remain 20px from the right of the viewport with any empty space being displayed on the left.
How can this be accomplished?
The current code follows:
HTML
<div id="grid_outer">
<div id="grid_inner">
<div class="grid_thumb button">
<span class="thumb_title">TITLE</span>
<img class="thumb_image" src="image.jpg" alt="TITLE">
</div>
<div class="grid_thumb button">
<span class="thumb_title">TITLE2</span>
<img class="thumb_image" src="image2.jpg" alt="TITLE2">
</div>
</div>
</div>
CSS
#grid_outer {display:none; position:absolute; background-color:rgba(0,0,0,0.75); right:20px; left:20px; bottom:60px; padding:20px 10px 10px 20px; border-radius:20px; max-height:480px; overflow:hidden;}
.grid_thumb {position:relative; float:left; margin:0 10px 10px 0; width:150px; height:150px;}
.thumb_image {position:absolute; top:0; left:0; border-radius:5px;}
.thumb_title {position:absolute; bottom:0px; left:0px; z-index:100; padding:8px; background:#000; border-radius:0 5px 0 5px;}
.button {cursor:pointer;}
So I've discovered that if I set the width of #grid_outer to auto, it will behave how I want if there's less than one row of thumbnails, but will stretch to the far left side of the viewport if there is more than one row of items. Can anyone help?
The CSS only solution (http://caniuse.com/#feat=css-sel3, http://caniuse.com/#feat=css-mediaqueries)
http://jsfiddle.net/coma/G7bx8/6/embedded/result/
div.grid {
font-size: 170px;
position: fixed;
max-width: 1em;
height: 3em;
bottom: 20px;
right: 20px;
padding: 5px;
background-color: rgba(0, 0, 0, .75);
border-radius: 20px;
overflow: auto;
}
div.grid:after {
display: block;
content: "";
clear: both;
}
div.grid > div {
width: 160px;
height: 160px;
float: left;
margin: 5px;
border-radius: 10px;
background-color: #009dff;
}
#media screen and (min-width: 410px) {
div.grid {
max-width: 2em;
}
div.grid > nth-child(2n) {
clear: right;
}
}
#media screen and (min-width: 550px) {
div.grid {
max-width: 3em;
}
div.grid > nth-child(3n) {
clear: right;
}
}
#media screen and (min-width: 720px) {
div.grid {
max-width: 4em;
}
div.grid > nth-child(4n) {
clear: right;
}
}
#media screen and (min-width: 890px) {
div.grid {
max-width: 5em;
}
div.grid > nth-child(5n) {
clear: right;
}
}
#media screen and (min-width: 1060px) {
div.grid {
max-width: 6em;
}
div.grid > nth-child(6n) {
clear: right;
}
}
#media screen and (min-width: 1230px) {
div.grid {
max-width: 7em;
}
div.grid > nth-child(7n) {
clear: right;
}
}
#media screen and (min-width: 1400px) {
div.grid {
max-width: 8em;
}
div.grid > nth-child(8n) {
clear: right;
}
}
#media screen and (min-width: 1570px) {
div.grid {
max-width: 9em;
}
div.grid > nth-child(9n) {
clear: right;
}
}
#media screen and (min-width: 1740px) {
div.grid {
max-width: 10em;
}
div.grid > nth-child(10n) {
clear: right;
}
}
The jQuery solution
http://jsfiddle.net/coma/G7bx8/7/embedded/result/
var size = 170;
var margin = 40;
var win = $(window);
var adjust = function() {
$('div.grid').each(function() {
var width = win.width() - margin;
width = Math.floor(width / size) * size;
$(this).width(width);
});
};
win.resize(adjust);
adjust();