Media query does not resizing fieldset and button - html

I'm trying to use media querys, but I have a problem. When I resized my window, it doesn't do anything when I resize the window, I try with different options, for example:
I have this:
#media all and (max-width: 900px) {
#breakdown-search-clear-button {
margin-left: 28% !important;
}
#historico-incidencias{
width: 36.1% !important;
margin-left: 62% !important;
margin-top: -27.8% !important;
}
}
or this
#media screen and (max-width: 900px) {
#breakdown-search-clear-button {
margin-left: 28% !important;
}
#historico-incidencias{
width: 36.1% !important;
margin-left: 62% !important;
margin-top: -27.8% !important;
}
}
at the end of my css file. And it doesn't work. I try first with "#media screen" and then with "#media all", but it doesn't work in both cases when I resize the window.
Then I try to put tag on my .jso file, as you can see on this example:
I write this tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
And, at the end of the tag I write this:
<style>
/* On screens that are 600px wide or less, the background color is olive */
#media screen and (max-width: 900px) {
#breakdown-search-clear-button {
margin-left: 28% !important;
}
#historico-incidencias{
width: 36.1% !important;
margin-left: 62% !important;
margin-top: -27.8% !important;
}
}
</style>
But it doesn't do anything when I resize the window as on the css file.
HTML elements:
<div id="breakdown-search-clear-button" class="roundedButtonMin roundedButtonRight deleteBG" style="margin-left: 24% !important; margin-top: 1% !important;"></div>
<fieldset style="width: 46.1%; margin-left: 52%; margin-top: -23%; display: inline-block; vertical-align: top;" id="historico-incidencias">
<legend>Histórico</legend>
<div id="listHistoricalIncidences"></div>
</fieldset>
Anyone can help me, please?
Thank you!

Related

Media query not responding on pc

I was using media query and it was working, but now it just stopped working, but if I use the developer tool of the browser the media query works well
Here is my media query code, but I dont think that that is the error
#media only screen and (max-width: 760px) and (max-device-width: 760px) {
.conainerInp {
display: block !important;
}
.contInputs,
.contInputs3 {
flex: 100% !important;
max-width: 100% !important;
margin-bottom: 10px;
width: 100%;
}
.last {
margin-bottom: 60px;
}
.contenido {
display: flex !important;
flex-wrap: wrap !important;
}
.contenedoresGen {
max-width: 100% !important;
width: 100% !important;
}
::ng-deep .mat-horizontal-content-container {
padding: 0 !important;
}
::ng-deep.mat-horizontal-stepper-content {
overflow: auto !important;
}
::ng-deep .mat-tab-label-container {
overflow-x: auto !important;
}
}
the screen was at a measure less thant the indicated in the media query
You need to add the following meta to your HTML in the head tag:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
I foun out the problem, it was my conditions, it neaded that the sceen be at 760px also the devie at the same time, I already had the meta tag before asking this, the solution was removing
and (max-device-width: 760px)
and it still working on movile because of the meta tag

How to make container take full width in phone devices using Bootstrap

No matter how I try in my CSS file, the container can't take full width in phone device.
my CSS file:
#media (max-device-width: 1024px) {
.col-sm-2{
width: 100%;
}
.container {
margin: 0 auto;
width: 100%;
}
.col-sm-10 {
width: 100%;
}
}
HTML:
<div class="container">
<h1 >Profile</h1>
</div>
Any suggestion?
You should use container-fluid class instead of container, or if would prefer you can use the sm, lg and so on suffixes , like container-sm
See the docs
Try container fluid
<div class="container-fluid">
<h1 >Profile</h1>
</div>
or add !important to #media like this
#media (max-device-width: 1024px) {
.col-sm-2{
width: 100%;
}
.container {
margin: 0 auto;
width: 100% !important;
padding: 0 !important;
}
.col-sm-10 {
width: 100% !important;
}
}

Bootstrap site is not being responsive

Mobile view of site
#media screen and (max-width: 600px) {
.sidebar {
width: 100% !important;
height: auto !important;
}
}
#media screen and (max-width: 600px) {
.content {
width: 100% !important;
margin-top: 20px !important;
}
#media screen and (max-width: 600px) {
.jdzn-footer-text img {
width: 100% !important;
}
}
#media screen and (max-width: 600px) {
.featured-card {
width: 100% !important;
}
}
I have already have the meta viewport tag, can anyone help me resolve this? Thanks.
Not sure what your viewport meta tag look like, but you may try replacing yours with this viewport meta tag in your index file.
<head>
...
<meta name="viewport" content="width=device-width, initial-scale=1.0">
...
</head>

Have an image only display on mobile

I am trying to create an email that shows one image only when viewed on mobile and one image only when viewed on desktop on desktop.
I have gotten the desktop image to correctly disappear when viewed on mobile, but I am unsure how to get the same result for the reverse.
Any help would be appreciated.
The CSS I am using is as follows:
#media screen and (max-width: 600px) {
.img-max {
width: 100% !important;
max-width: 100% !important;
height: auto !important;
}
.max-width {
max-width: 100% !important;
}
.mobile-wrapper {
width: 85% !important;
max-width: 85% !important;
}
.mobile-padding {
padding-left: 5% !important;
padding-right: 5% !important;
}
/* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
.mobile-hide {
display: none !important;
}
.mobile-show {
display: block !important;
}
}
And the HTML
<img class="mobile-show" border="0" height="50" src="images/logo.svg" style="display: block;" width="250">
<img class="mobile-hide" border="0" height="50" src="images/logo.svg" style="display: inline;" width="100">
Need to setup a second media screen:
#media screen and (min-width: 600px) {
/* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
.mobile-hide {
display: none !important;
}
}
First of all add this meta tag for mobile deivce support if its missing like below.
<meta name="viewport" content="width=device-width, initial-scale=1">
Then using media queries you can achieve the thing you want.
#media screen and (max-width: 600px) {
.mobile-hide {
display: none !important;
}
.mobile-show {
display: block !important;
}
}
.mobile-hide {
display: block;
}
.mobile-show {
display: none;
}
#media screen and (max-width: 600px) {
.mobile-hide {
display: none !important;
}
.mobile-show {
display: block !important;
}
}
.mobile-hide {
display: block;
}
.mobile-show {
display: none;
}
You have to hide your mobile image always except in the mobile. So add a display:none to your image. Then your image will not appear no desktop and your CSS with medi will make it appear.
<img class="mobileShow" border="0" height="50" src="images/logo.svg" style="display: none;" width="250">
.desk-hide {
display: none !important;
}
.desk-show {
display: block !important;
}
#media screen and (max-width: 600px) {
.img-max {
width: 100% !important;
max-width: 100% !important;
height: auto !important;
}
.max-width {
max-width: 100% !important;
}
.mobile-wrapper {
width: 85% !important;
max-width: 85% !important;
}
.mobile-padding {
padding-left: 5% !important;
padding-right: 5% !important;
}
/* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
.mobile-hide {
display: none !important;
}
.mobile-show {
display: block !important;
}
}
<img class="mobile-show desk-hide" border="0" src="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon#2.png" style="display: block;">
<img class="mobile-hide desk-show" border="0" src="https://www.socialtalent.co/wp-content/uploads/blog-content/so-logo.png" style="display: inline;" />
You've created two classes for handling the mobile size behavior. Now, you have to do the same for desktop size. If you want this to work as intended, place the desktop size rules above the #media. So in the default screen size, the desktop rules are being applied, but when screen became less than 600px, it will apply the #media rules.
You can use picture tag which can use many image sources, example:
<picture>
<source srcset="images/logo-mobile.png" media="(max-width: 720px)">
<img src="images/logo.png">
</picture>
Are tablets mobile in your opinion or do you just want mobile phones? With todays phones and tablets it's unreliable to trust a simple media query like:
#media screen and (max-width: 600px) { }
Best way in my opinion is to use Javascript or PHP ( this PHP class is very interesting github.com/serbanghita/Mobile-detect ) to detect what device is being used and then apply the right style.
Its light, reliable and gives you all the data over what devices do your users have and it's always handy to know not just the device but also resolution, pixel depth, etc. & have even different image files for different users.

CSS Media Query Not Loading

I'm writing a static website and testing it locally. I have written a media query to change the layout a little bit so that it is much nicer to look at on a smartphone. With the media query my aim is to change the text and the profile photo from being side by side to being one followed by the other.
My issue is that when I load the HTML file on Chrome or Firefox and resize the window, the layout does not change and I cannot figure out how to fix it. Any help would be much appreciated. Find my code below.
For my standard CSS I have this (a small snippet):
#about-text {
/*A div containing paragraphs and a table*/
display: inline-block;
width: 50%;
}
#profile-photo {
/*An img tag after the closing about-text div*/
border: 4px solid #1abc9c;
display: inline;
float: right;
margin: 8% 0% 0% 0%;
max-width: 40%;
}
And then I have a media query and the corresponding CSS:
#media (min-device-width : 320px) and (max-device-width : 480px) {
#about-text {
/*A div containing paragraphs and a table*/
display: block;
width: 50%;
}
#profile-photo {
/*An img tag after the closing about-text div*/
border: 4px solid #1abc9c;
display: block;
float: right;
margin: 8% 0% 0% 0%;
max-width: 40%;
}
}
You are using min-device-width and max-device-width which only takes into the account the device's screen size. Use min-width and max-width and it will work in your browser when you resize.
Example:
.testDiv {
color: green;
}
#media (min-width : 320px) and (max-width : 480px) {
.testDiv {
color: red;
}
}
http://jsfiddle.net/ZUPD2/
Maybe because there is no closing bracket for the media query block ?