Fixed position image not being display on old blackberrys - html

I have an image (that I'm adding to a page with javascript) I want to display at the bottom of my screen (not at the bottom of the content ).
Everything seems to work fine except for older blackberry's. Any idea where I'm going wrong?
In my html I have
<div id="sticky" class="banner-sticky" style="position: fixed;">
</div>
and in my css I have
.banner-sticky {
bottom: 0px;
left: 0px;
width: 100%;
text-align: center;
background: rgb(0, 0, 0) transparent;
background: rgba(0, 0, 0, 0);
/* filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";*/
-webkit-backface-visibility:hidden;
}
.advert-img {
width: 90%
height: 100%;
}
#media only screen and (min-width: 320px) {
.advert-img {
width: 90%
}
}
#media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
only screen and ( min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min-resolution: 192dpi) and (min-width: 320px),
only screen and ( min-resolution: 2dppx) and (min-width: 320px) {
.advert-img {
width: 90%
}
}
#media only screen and (min-width: 700px) {
.advert-img {
width: 50%
}
}
#media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 700px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 700px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 700px),
only screen and ( min-device-pixel-ratio: 2) and (min-width: 700px),
only screen and ( min-resolution: 192dpi) and (min-width: 700px),
only screen and ( min-resolution: 2dppx) and (min-width: 700px) {
.advert-img {
width: 50%
}
}
#media only screen and (min-width: 1300px) {
.advert-img {
width: 30%
}
}
#media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 1300px),
only screen and ( min-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( min-resolution: 192dpi) and (min-width: 1300px),
only screen and ( min-resolution: 2dppx) and (min-width: 1300px) {
.advert-img {
width: 30%
}
}
The generated html after the javascript does its thing:
<div style="position: fixed;" class="banner-sticky" id="sticky">
<a href="http://ad.vic-m.co:80/landingpage?pr=21&ar=GoM;ht=245" id="ad-link">
<span id="banner-ad"><img src="http://ad.vic-m.co:8080/AdService/fileHandleAction?file=7A10B19B-2E51-4CCE-AB6A-319C382B4AA8" class="advert-img">
</span>
</a>
</div>

Related

How to replace header background image for mobile - bootstrap

I can't figure out how to serve different image for mobile users - my banner become too small to read. I am kinda new to this. I successfully managed to put banner image where it should be using bootstrap, with help of following css code:
.jumbotron{
margin-top: 5px;
background-image: url(obr/head.jpg);
background-size: cover;
height: 100%;
background-size:100% auto;
background-repeat: no-repeat;
min-height: 320px;
}
and html
<header class="jumbotron">
</header>
Note that I had to set min-height: 320px; because it was the only way to display banner in correct size (apart from adding br's in header tag). On mobile, banner is small to read and also creates white space because of min-height..
I tried to serve different image for mobile users using this css code:
/* Custom, iPhone Retina */
#media only screen and (min-width : 320px) {
.jumbotron{
background-image: image-url("obr/head_mobile.png");
}
}
/* Extra Small Devices, Phones */
#media only screen and (min-width : 480px) {
.jumbotron{
background-image: image-url("obr/head_mobile.png");
}
}
/* Small Devices, Tablets */
#media only screen and (min-width : 768px) {
.jumbotron{
background-image: image-url("obr/head_mobile.png");
}
}
/* Medium Devices, Desktops */
#media only screen and (min-width : 992px) {
.jumbotron{
background-image: image-url("obr/head.jpg");
}
}
/* Large Devices, Wide Screens */
#media only screen and (min-width : 1200px) {
.jumbotron{
background-image: image-url("obr/head.jpg");
}
}
but no luck. Can anyone help me sorting this out? I prefer easy to follow steps to take.
Thank you so much.
Media Queries do not begin with # they are started by a # sign.
background-image: image-url("obr/head_mobile.png"); is not a property. Use background-image: url("img-path");. Then it will work fine.
EXAMPLE
#media only screen and (max-width: 500px) {
body {
background-color: blue;
}
}
Your Code Correction:
/* Custom, iPhone Retina */
#media only screen and (min-width : 320px) {
.jumbotron {
background-image: url("obr/head_mobile.png");
}
}
/* Extra Small Devices, Phones */
#media only screen and (min-width : 480px) {
.jumbotron {
background-image: url("obr/head_mobile.png");
}
}
/* Small Devices, Tablets */
#media only screen and (min-width : 768px) {
.jumbotron {
background-image: url("obr/head_mobile.png");
}
}
/* Medium Devices, Desktops */
#media only screen and (min-width : 992px) {
.jumbotron {
background-image: url("obr/head.jpg");
}
}
/* Large Devices, Wide Screens */
#media only screen and (min-width : 1200px) {
.jumbotron {
background-image: url("obr/head.jpg");
}
}
Learn more about media queries: https://www.w3schools.com/cssref/css3_pr_mediaquery.asp
.
See the working code here: https://codepen.io/manaskhandelwal1/pen/NWqdOPZ

Hide/Show Div on a onepage layout dependant on Device

I want to create a website (one page responsive) where on a full width screen tablet/monitor it shows a slider, but on a mobile device it hides the slider and shows a full screen hero/splash div.
I am aware that this will include #media but not sure about which syntax to use.
You can use css media query like below. More
#media only screen and (max-width: 768px) {
.your-class{
display: none;
}
}
#media and Bootstrap providing options to hide/show your div based on screen size
Bootstrap: hidden-md, hidden-lg, visible-lg etc. Bootstrap Responsive utilities
You can use #media as below
style.css
#media (max-width: 480px) {
/* some class with properties */
}
#media (max-width: 576px) {
/* some class with properties */
}
#media (min-width: 577px) and (max-width:767px) {
/* some class with properties */
}
#media (min-width: 768px) {
#left-side-bar{
top:44px;
width: 200px;
}
}
#media (min-width: 992px) {
.web-content{
text-align: right;
}
}
#media (min-width: 1200px) {
.right-side-bar{
display: block;
}
}
You can use media queries by specifying device width.
#media (max-width: 768px)
{
.some-selector
{
display: none;
}
}
For queries for some standard devices refer -
https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
#media only screen and (max-width: 768px) {
.class{
display: none;
}
}
And if you want hide any other device
/* 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 */
}
/**********
iPad 3
**********/
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* 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 (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
#media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* iPhone 5 ----------- */
#media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
#media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6 ----------- */
#media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
#media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6+ ----------- */
#media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
#media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S3 ----------- */
#media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
#media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S4 ----------- */
#media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
#media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
/* Samsung Galaxy S5 ----------- */
#media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
#media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

I am having trouble with this query (only iPad). It is not being picked up while iPhone landscape and portrait work fine

I am having trouble with this query (only iPad). It is not being picked up while iPhone landscape and portrait work fine
/*iPhone 6 Portrait*/
#media only screen and (min-device-width: 375px) and (max-device-width:
667px) and (orientation : portrait) {
body {
background: red;
}
}
/*iPhone 6 landscape*/
#media only screen and (min-device-width: 375px) and (max-device-width:
667px) and (orientation : landscape) {
body {
background: green;
}
}
/* iPad Air */
#media only screen and (device-width: 768px) and (device-height: 1024px) and
(orientation : landscape) {
body {
background: yellow;
}
for my web

Make background img responsive

I'm trying to make a background the same height and widt as the picture which is selected in the background property.
And I would like the heigth and width to be responsive and not static.
I know it can be done with an image, but would like it to be a background if it is possible?
<div style="background:url('http://cdn.lolhappens.com/wp-content/uploads/2013/06/Aww-in-a-picture.jpg'); background-size:100%"></div>
A simple fiddle here
And I would like it to have same effect as if you use an image as this example
I solved it like this:
I found my anwser here
The fix in short, was to make a transparent picture and then have a div to that img container like this:
<div style="background:url('background.jpg'); background-size:100% 100%; width:100%; height:100%">
<img src="transparent.png" style="width:100%" />
</div>
/* default screen, non-retina */
.hero { background-image: url("../img/candc970.jpg"); }
#media only screen and (max-width: 320px) {
/* Small screen, non-retina */
.hero { background-image: url("../img/candc290.jpg"); }
}
#media
only screen and (min-resolution: 2dppx) and (max-width: 320px) {
/* Small screen, retina */
.hero { background-image: url("../img/candc290#2x.jpg"); }
}
#media only screen and (min-width: 321px) and (max-width: 538px) {
/* Medium screen, non-retina */
.hero { background-image: url("../img/candc538.jpg"); }
}
#media
only screen and (min-resolution: 2dppx) and (min-width: 321px) and (max-width: 538px) {
/* Medium screen, retina */
.hero { background-image: url("../img/candc538#2x.jpg"); }
}
#media
only screen and (min-resolution: 2dppx) and (min-width: 539px) {
/* Large screen, retina */
.hero { background-image: url("../img/candc970#2x.jpg"); }
}
you can mange with CSS
add background-size:100% 100% to your style
div {
background:url('http://cdn.lolhappens.com/wp-content/uploads/2013/06/Aww-in-a-picture.jpg') no-repeat;
width:100%; /* make sure you have set this */
height:100%; /* make sure you have set this */
background-size:100% 100%
}
demo here
#media screen and (max-width: 380px) {
.hero
{
background-image: url("../img/IMGBIG.jpg");
}
}
#media screen and (max-width: 320px) {
.hero
{
background-image: url("../img/IMGSMALL.jpg");
}
}

screen orientation for multiple tablets with fluid design

So i'm making a mobile web application that is supposed to take up a 100% of the screen without scrolling (in either direction).
I have fixed positions for the different area's of the screen.
html, body{
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
.site-header{
position: fixed;
top: 0px;
height: 10%;
background: red;
width: 100%;
}
.site-article{
position: fixed;
top: 10%;
bottom: 10%;
background: white;
width: 95%;
}
.site-footer{
position: fixed;
bottom: 0px;
height: 10%;
background: blue;
width: 100%;
}
.site-nav{
position: fixed;
top: 10%;
bottom: 10%;
right: 0px;
background: green;
width: 5%;
}
I know there are media queries for css like the following
#media only screen and (orientation:portrait)
Where you can switch the orientation between portrait and landscape, but I can't think of anything to put between the two orientations as the width and height both need to stay 100% for each correct?
It displays correctly on my ipad, then you change the orientation and scrolling is needed (both horizontally and vertically). If I keep the orientation and refresh the page, it loads the page with the correct positions.
Is there anyway to do this using media queries with css or am I going to have to dive into some javascript? I need to be able to support multiple mobile devices, from android phones and tablets to ios phones and tablets.
Just FYI. Height 100% only extends to the bottom of the viewport. Anyways, instead of using orientation try using min-width and min-height media queries. And set up different break points for different resolutions.
/* 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 */
}