I am trying to use media query to display text box with different styles for iPhone5,iPhone6,Samsung galaxy SIII and Samsung galaxy S4. For iPhone 5 and IPhone 6 I am getting desirable result. Now when I switch from iPhone to Samsung s3 I am getting correct output but when I try to switch to S4 from S3 I am getting wrong output. Here's the style that I am using for media query. Attaching the screenshots also. I am not getting the actual problem here.
<style>
#media only screen and (device-width:375px){
.homeDOB{
width:60% !important;
height:80px !important;
background-color: yellow;
} }
#media only screen and (device-width:320px) {
.homeDOB{
width:60% !important;
height:80px !important;
background-color: black;
} }
#media only screen and (device-width:360px) and (device-height:640px) and (-webkit-min-device-pixel-ratio:2){
.homeDOB{
width:60% !important;
height:80px !important;
background-color: gray;
}
}
#media only screen and (device-width:360px) and (device-height:640px) and (-webkit-min-device-pixel-ratio:3){
.homeDOB{
width:60% !important;
height:80px !important;
background-color: red;
}
}
</style>
For Galaxy S4, device width it hits at is a little over 400px. Try changing your media query to:
#media screen and (max-width: 480px) {
.homeDOB {
width:60% !important;
height:80px !important;
background-color: black;
}
}
and see if it work on your mobile phone. Also, this is the viewport must use:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
device width for samsung galexy s3 and s4 is 640px.
Try this
#media only screen and (max-width:640px){
//your CSS rules
}
Here you can find list of device width/height http://www.canbike.org/CSSpixels/
Related
I have a progressive web app developed in reactjs and in this
I am using banner images which look good on mobile view, but when I switch to laptop view the banner images look big.
I tried to set the height property, but the image looks squeezed on laptop view.
The CSS code for the same is pasted below
banner-container {
padding: 20px;
margin-top: 45px;
.banner-img {
max-width: 100%;
height: auto;
}
}
#media (min-width: 767px) {
.banner-container {
padding: 20px;
margin-top: 200px !important;
max-width: 100%;
.banner-img {
width: 100%;
height: auto;
max-height: 300px;
}
}
}
What is the best way to display banner images which look good on both laptop and mobile view
You can easily manage your banner image with this css property:
object-fit: contain
Or you can look into different values of object-fit in this doc:
https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
Ok the question has been asked many time before and I went through each and everyone of them but it didn't worked for me
In mobile view I want to set slideshow col position from Relative to Static which will result into this
But instead I'm seeing this on mobile (adjacent col is overlapping)
which means Col is still in relative position and media Queries are not working on mobile platforms however It does work in Desktop Chrome browser.
I used meta tags and different combinations of min and max values (after confirming screen resolution)
for example
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-width : 320px)
and (max-width : 480px) {
section.banner .slideshow-col{
position: static;
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 320px) {
section.banner .slideshow-col{
position: static;
}
#media (min-width : 700px) {
section.banner .slideshow-col{
position: static;
}
#media (min-width: 992px) {
section.banner .slideshow-col{
position: relative;
}}
#media (min-width: 1200px) {
section.banner .slideshow-col{
position: relative;
}}
My website is here http://
Any hint?
Try to use this solutions
#media screen and (max-width: 760px){
.slideshow-col {
position: relative;
height: 300px; <-- height of the slideshow
// You can use min & max height of slideshow for mobile devices
height: auto;
min-height: xxx;
max-height: xxx;
}
}
I just want to change the height of Foundation 5's Top-Bar Navigation depending on the screen size.
For example the height of the top-bar on small-screen should be 100px,
on medium screens and larger the height should be 150px.
Thanks for your help!
Markus
Add this to your css
.top-bar {
height: 150px;
line-height: 150px;
}
Media query for mobile screens
#media only screen and (max-width: 40em) {
.top-bar{
height: 100px;
line-height: 100px;
}
}
I have developed a website(www.damabbs.com) using Bootstrap. The problem is the webpage is draggable horizontally when user wants to scroll down using iPhone safari. It is very annoying.
I have checked with bootstrap website. It works fine. It can only be draggable vertically.
Change that code in base.css line 34
#media ( max-width : 766px) {
body {
padding-top: 0;
padding-left: 5px !important;
padding-right: 5px !important;
}
to
#media ( max-width : 766px) {
body {
padding-top: 0;
padding-left: 10px !important;
padding-right: 10px !important;
}
What code can I use to make a particular div show only if on a mobile width?
I have a 100% width full div at the top of my screen, would like it to only show when the device is specified as a mobile width.
I'm not sure, what you mean as the 'mobile width'. But in each case, the CSS #media can be used for hiding elements in the screen width basis. See some example:
<div id="my-content"></div>
...and:
#media screen and (min-width: 0px) and (max-width: 400px) {
#my-content { display: block; } /* show it on small screens */
}
#media screen and (min-width: 401px) and (max-width: 1024px) {
#my-content { display: none; } /* hide it elsewhere */
}
Some truly mobile detection is kind of hard programming and rather difficult. Eventually see the: http://detectmobilebrowsers.com/ or other similar sources.
It sounds like you may be wanting to access the viewport of the device. You can do this by inserting this meta tag in your header.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
http://www.w3schools.com/css/css_rwd_viewport.asp
Small devices (landscape phones, 576px and up)
#media (min-width: 576px) {
#my-content{
width:100%;
}
// Medium devices (tablets, 768px and up)
#media (min-width: 768px) {
#my-content{
width:100%;
}
}
// Large devices (desktops, 992px and up)
#media (min-width: 992px) {
display: none;
}
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) {
// Havent code only get for more informations
}