CSS Responsive issue with iPad Mini in NON-landscape mode (Vertical) - html

I'm having an issue with media query. I set the first on at 770px, so that it would re-size without putting the sidebar underneath the main content.
I then set the second media query at 740 (it was at 450, but I changed to 740 for the iPad Mini), thinking this would send the side-bar underneath the main content. (meaning that if held the iPad Mini vertically, it would look the same as it does on iPhone).
This works on my iPhone, but on iPad mini it keeps the 770px settings when viewed vertically (non-landscape mode).
What am I doing wrong? I assumed 740 would be high enough max-width, given that 770 works for landscape mode.
Here is the site: http://www.insidemarketblog.com
and here's the code
HTML:
div class="container">
<div class="columns">
<div class="content">
<div id="post-1" class="post_box grt top" itemtype="http://schema.org/Article" itemscope="">
<div id="comments">
<div class="prev_next"> </div>
</div>
<div class="sidebar" style="height: 560px;">
</div>
CSS:
#media all and (max-width: 740px) {
.container, .landing .container {
width: auto;
/*max-width: 720px;*/
/*max-width: $w_content;*/
max-width: 100%;
}
.header {
border-top: 1px solid $color1;
}
.landing .header {
border-top: 0;
}
.columns > .content {
/*float: left;*/
float: none;
/*width: 445px;*/
width: 100%;
border: 0;
}
.columns > .sidebar {
/*float: right;*/
float: none;
/*width: 275px;*/
width: 100%;
border-top: 3px double $color1;
}
.menu a, .menu_control {
padding: 1em $x_half;
background-color: #C24F43;
}
.header, .columns > .sidebar, .post_box, .prev_next, .comments_intro, .comment, .comment_nav, #commentform, .comment_form_title, .footer {
padding-right: $x_half;
/*padding-left: $x_half;*/
}
.menu .sub-menu, .children .comment {
padding-left: $x_half;
}
.comments_closed, .login_alert {
margin-right: $x_half;
margin-left: $x_half;
}
.comment_form_title {
margin-left: -$x_half;
margin-right: -$x_half;
}
.right, .alignright, img[align="right"], .left, .alignleft, img[align="left"] {
float: none;
}
.grt .right, .grt .left, .post_box .alignright, .post_box .alignleft, .grt blockquote.right, .grt blockquote.left {
margin-right: 0;
margin-left: 0;
}
.post_author:after {
content: '\a';
height: 0;
white-space: pre;
display: block;
}
.grt blockquote.right, .grt blockquote.left, #commentform .input_text, .sidebar .search-form .input_text, .sidebar .thesis_email_form .input_text {
width: 100%;
}
.post_box blockquote {
margin-left: 0;
}
.comment_date {
display: none;
}
}

Try this media query.
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-width : 768px)
and (max-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-width : 768px)
and (max-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-width : 768px)
and (max-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}

Related

Different between landscape and portrait Media Query

I am sitting and reading on this page
Media Query
It says here:
/* iPads (landscape) ----------- / #media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and
(orientation : landscape) { / Styles */ }
/* iPads (portrait) ----------- / #media only screen and
(min-device-width : 768px) and (max-device-width : 1024px) and
(orientation : portrait) { / Styles */ }
But there is no difference in those two codes? That result in that I make my elements fit on fx landscape mode. Then I go to Portrait mode, and everything is flying around.
How can I design the responsive, so I seperate Portrait and Landscape mode?
CSS
/* iPads (portrait) ----------- */
#media only screen and (min-width : 768px) and (max-width : 1024px) {
.ebook-image {
width: 600px;
display: block;
margin: 0 auto;
margin-top: -30px;
}
.ebook-image img {
margin-left: 0px;
}
.header-box {
background-color: #163A4E;
height: 680px;
margin-bottom: 0px;
padding: 0px;
}
.header-text h1 {
font-weight: 900;
font-size: 40px;
line-height: 1;
text-transform: uppercase;
color: #fff;
position: relative;
left: 0px;
top: -10px;
}
.header-text h2 {
font-size: 20px;
margin-bottom: 25px;
font-weight: 900;
color: #fff;
position: relative;
left: 0px;
top: -30px;
text-align: center;
}
}
iPads (landscape) -----------
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
.ebook-image {
height: 500px;
width: 590px;
}
.ebook-image img {
margin-left: -190px;
padding-top: 0px;
}
.header-box {
background-color: #163A4E;
height: 350px;
margin-bottom: 0px;
padding: 0px;
}
.header-text h1 {
font-weight: 900;
font-size: 40px;
line-height: 1;
text-transform: uppercase;
color: #fff;
position: absolute;
left: -400px;
top: 110px;
}
.header-text h2 {
font-size: 20px;
margin-bottom: 25px;
font-weight: 900;
color: #fff;
position: absolute;
left: -405px;
top: 150px;
}
}
The queries are quite different; note the trailing and (orientation : landscape) and and (orientation : portrait) in both media queries.
Here's a fiddle that demonstrates these queries by applying a different background color when viewed in landscape or portrait mode.
https://jsfiddle.net/dem49e87/2/show/
Make sure to open it on your phone and check it out in both portrait and landscape mode.
#media (min-width: 700px) and (orientation: landscape)
This way you make sure you combine a min-width with the orientation of the device. You can (and should) use the orientation markup for your layouts if you have different behaviours.

Liquid Layers - display:none doesnt work

I'm trying to play with "Fluid Layers" and when resizing the window (manually resizing its width), I want to make: display:none on one of the Divs but it fails to do so (simply doesn't work).
Can you tell me why display:none on line 18 doesn't work?. And in addition, Should I use DIVS when i want to center 3 blocks inside a container? or you have a better idea for me?.
Would be happy to get a better / different ideas of implementing Liquid Layers if you know any. thank you for your help.
Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body
{
background-color: #FFFFFF;
}
/* Extra small devices (phones, up to 480px) */
#media (max-width: 480px)
{
body
{
background-color: #FFFFFF;
}
.col3 { display: none; }
}
/* Extra small devices (usually phones from 480px to 768px) */
#media (min-width: 481px) and (max-width: 767px)
{
body
{
background-color: yellow;
}
}
/* Small devices (tablets, 768px and up) */
#media (min-width: 768px) and (max-width: 991px)
{
body
{
background-color: #444;
}
}
/* Small devices (tablets / desktop, 768px and up) */
#media (min-width: 992px) and (max-width: 1199px)
{
body
{
background-color: green;
}
}
/* large desktops and up ----------- */
#media (min-width: 1200px)
{
body
{
background-color: lightblue;
}
}
</style>
</head>
<body>
<div style="width:100%; margin-left: 0 auto; background-color:#422220; text-align:center; overflow: hidden; padding:10px 0px;">
<div id="col1" style="width:29%; padding: 0; margin-left: 3%; margin-right:3%; background-color:#FFF333; display: inline- block">Text</div>
<div id="col2" style="width:29%; padding: 0; margin-right:3%; background-color:#FFF333; display: inline-block">Text</div>
<div id="col3" style="width:29%; padding: 0; margin-right:3%; background-color:#FFF333; display: inline-block">Text</div>
</div>
</body>
</html>
You used a class instead of an id as the selector.
Also i moved the common style for all the cols to the stylesheet instead of the inline style as you did.
body {
background-color: #FFFFFF;
}
#col1,
#col2,
#col3 {
width: 29%;
padding: 0;
margin-left: 3%;
margin-right: 3%;
background-color: #FFF333;
display: inline-block;
}
/* Extra small devices (phones, up to 480px) */
#media (max-width: 480px) {
body {
background-color: #FFFFFF;
}
#col3 {
display: none;
}
}
/* Extra small devices (usually phones from 480px to 768px) */
#media (min-width: 481px) and (max-width: 767px) {
body {
background-color: yellow;
}
}
/* Small devices (tablets, 768px and up) */
#media (min-width: 768px) and (max-width: 991px) {
body {
background-color: #444;
}
}
/* Small devices (tablets / desktop, 768px and up) */
#media (min-width: 992px) and (max-width: 1199px) {
body {
background-color: green;
}
}
/* large desktops and up ----------- */
#media (min-width: 1200px) {
body {
background-color: lightblue;
}
}
<div style="width:100%; margin-left: 0 auto; background-color:#422220; text-align:center; overflow: hidden; padding:10px 0px;">
<div id="col1">Text</div>
<div id="col2">Text</div>
<div id="col3">Text</div>
</div>

CSS Media Queries - Not Working

I have a set of breakpoints that I am trying to work with and am using the following CSS code to change css rules however the rules are only being applied to screens over 1200px wide and not the others.
/* Large Desktop Devices */
#media (min-width: 1200px) {
.header {
height: 120px;
}
}
/* Small Desktop Devices and iPad Landscape */
#media (min-width: 1024px) and (max-width: 1199px) {
.header {
height: 120px;
}
}
/* iPad and Tablets Potrait */
#media (min-width: 768px) and (max-width: 1023px)
.header {
height: 100px;
}
}
/* Large Screen Phones */
#media (min-width: 480px) and (max-width: 767px)
.header {
height: 90px;
}
}
/* Small Screen Phones */
#media (min-width: 320px) and (max-width: 479px)
.header {
height: 80px;
}
}
If anyone can see why this isn't working, I would love to know!
Thanks
use like this
#media screen and (max-width:1200px)
#media only screen and (max-width:1200px)
ensure you have added viewport metatag in your page
<meta name="viewport" content="width=device-width, initial-scale=1">
also You are missing opening braces on the last 3 statements
/* Large Desktop Devices */
#media (min-width: 1200px) {
.header {
height: 120px;
}
}
/* Small Desktop Devices and iPad Landscape */
#media (min-width: 1024px) and (max-width: 1199px) {
.header {
height: 120px;
}
}
/* iPad and Tablets Potrait */
#media (min-width: 768px) and (max-width: 1023px){
.header {
height: 100px;
}
}
/* Large Screen Phones */
#media (min-width: 480px) and (max-width: 767px){
.header {
height: 90px;
}
}
/* Small Screen Phones */
#media (min-width: 320px) and (max-width: 479px)
.header {
height: 80px;
}
}
hope it helps.
/* Large Desktop Devices */
#media screen and (min-width: 1200px){
.header {
height: 120px;
}
}
/* Small Desktop Devices and iPad Landscape */
#media screen and (min-width: 1024px) and (max-width: 1199px) {
.header {
height: 120px;
}
}
/* iPad and Tablets Potrait */
#media screen and (min-width: 768px) and (max-width: 1023px) {
.header {
height: 100px;
}
}
/* Large Screen Phones */
#media screen and (min-width: 480px) and (max-width: 767px) {
.header {
height: 90px;
}
}
/* Small Screen Phones */
#media screen and (min-width: 320px) and (max-width: 479px) {
.header {
height: 80px;
}
}
You need to change it to # media all and (max-width: 480px)

Max-width on mobile (full-width div)

I have a blue bar that runs along the top of my page that fills the full width of the screen, however, I can't get it to stick to a max-width.
On mobile it renders with an enormous amount of extra spacing on the right-hand side.
Any ideas?
You can see the code and CSS in action here:
http://jsfiddle.net/DavidMichaelangelo/4vj0gfp1/1/
HTML
<body>
<div id="main-logo" class="clearfix">
<div style="height: 26px; width: 174px; background-color: #000; color: #FFF;">Placeholder</div>
</div>
<div class="blue-line-headline clearfix">
<div class="blue-line-content clearfix">
<span style="font-size:1.25em;">Open an Account and</span><br />
<span style="font-size:3em; font-weight: bold;">Save XX% for X months*</span>
</div>
</div>
</body>
CSS
.blue-line-headline {box-shadow: 0 1px 3px rgba(0,0,0,.3); z-index: 15; color: #fff; width:100%; background-color:#1C3F94; padding: 0.5em 400%; margin: 0 -400%; max-width: 1100px; display: block;}
.blue-line-content {padding: 0px 0px 0px 20px; margin: auto; width: 100%; position: relative; display: block;}
#main-logo {padding: 20px 0px 20px 20px;}
Fix this
.blue-line-headline {box-shadow: 0 1px 3px rgba(0,0,0,.3); z-index: 15; color: #fff; width:100%; background-color:#1C3F94; padding: 0.5em 400%; margin: 0 -400%; max-width: 1100px; display: block;}
to
.blue-line-headline {box-shadow: 0 1px 3px rgba(0,0,0,.3);color: #fff; width:100%; background-color:#1C3F94;max-width: 1100px;}
Also, adding box-sizing: border-box; to blue-line-content will remove extra width from padding.
I updated your jsfiddle here http://jsfiddle.net/4vj0gfp1/7/.
In CSS3 you can use the vw as unit. It stands for visual width.
body{
padding: 0;
margin: 0;
}
.blue-line-headline {
box-shadow: 0 1px 3px rgba(0,0,0,.3);
z-index: 15;
color: #fff;
width:100vw;
background-color:#1C3F94;
padding: 0.5em 0;
margin: 0;
max-width: 1100px;
display: block;}
.blue-line-content {
padding: 0px 0px 0px 20px;
}
#main-logo {padding: 20px 0px 20px 20px;}
Bro try this and see.
If you want to determine whether its mobile, tab or pc use this code.
/* Smartphones (portrait and landscape
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) -----------
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- *
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pi
only screen and (min-device-pixel-ratio
/* Styles */
}
Url of code

Making the CSS theme responsive

Following is CSS code for all my web pages:
/* Site Colors:
#1A446C - blue grey
#689DC1 - light blue
#D4E6F4 - very light blue
#EEE4B9 - light tan
#8D0D19 - burgundy
*/
html { height: 100%; width: 100%; }
body { width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif; background: #D4E6F4;
font-size: 13px; line-height: 15px; }
img { border: none; }
table, tr, td { border-collapse: collapse; vertical-align: top; font-size: 13px; line-height: 15px;}
a { color: #8D0D19;}
#header { height: 70px; margin: 0px; padding: 0px; text-align: left;
background: #1A446C; color: #D4E6F4; }
#header h1 { padding: 1em; margin: 0px;}
#main { margin: 0px; padding: 0px; height: 600px; width: 100%; background: #EEE4B9; }
#structure { height: 600px; width: 100%; }
#footer { height: 2em; margin: 0px; padding: 1em; text-align: center;
background: #1A446C; color: #D4E6F4; }
/* Navigation */
#navigation { width: 150px; padding: 1em 2em; color: #D4E6F4; background: #8D0D19; }
#navigation a { color: #D4E6F4; text-decoration: none; }
ul.subjects { padding-left: 0; list-style: none; }
ul.pages { padding-left: 2em; list-style: square; }
.selected { font-weight: bold; }
/* Page Content */
#page { padding-left: 2em; vertical-align: top; background: #EEE4B9; }
#page h2 { color: #8D0D19; margin-top: 1em;}
#page h3 { color: #8D0D19; }
Problem is that once I have sufficient text to add to a web page, some part of the text goes out of bound and gets visible in white background(outside the light tan).Can anyone tell me necessary changes I need to make.
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Use this code and customize won work