#media section styles are not being applied; other #media sections working - html

I'm editing a pre-existing stylesheet. It currently has #media sections for 0-319px and for 320-479px, as well as a few others for larger screens. I'm trying to add iphone-specific styles. However, my iphone's screen is 320px, but I don't want to put iphone styles in the 320-479 section, because I only want it to be applied to the iphone, not tablets. So, I added a new section to the end of my stylesheet that goes up to 329px, and put the specific styles in there, but they are not being recognized.
#media screen and (min-width: 0px) and (max-width: 319px) {
.carousel-slide-dialog {
position: relative !important;
margin-top: 1px;
height: auto;
padding: 0 0 24px 25px;
width: 100%;
background-color: #de0662;
}
}
#media screen and (min-width: 320px) and (max-width: 479px) {
.carousel-slide-dialog {
position: relative !important;
margin-top: 1px;
height: auto;
min-height: 90px;
padding: 0 0 24px 25px;
width: 100%;
background-color: #de0662;
}
}
#media screen and (max-width: 329px) {
.carousel-slide-dialog {
min-height: 115px;
}
.carousel-slide-dialog p {
max-width: 235px;
}
}
When I look at the stylesheet in dev tools, my new section is there, so it's not a cache issue. But it's not being applied (I have my window size at 323px).

Your first two media queries are mostly the same, with the exception of the min-height attribute in 320-479. Also, #media screen and (min-width: 0px) and (max-width: 319px) is the essentially the same thing as just #media screen and (max-width: 319px)
Why don't you refactor the media queries so that there are not overlapping media queries, like this:
#media screen {
.carousel-slide-dialog {
position: relative !important;
margin-top: 1px;
height: auto;
padding: 0 0 24px 25px;
width: 100%;
background-color: #de0662;
}
}
#media screen and (max-width: 319px) {
.carousel-slide-dialog {
min-height: initial;
}
.carousel-slide-dialog p {
max-width: initial;
}
}
#media screen and (min-width: 320px) and (max-width: 329px) {
.carousel-slide-dialog {
min-height: 115px;
}
.carousel-slide-dialog p {
max-width: 235px;
}
}
#media screen and (min-width: 330px) and (max-width: 479px) {
.carousel-slide-dialog {
min-height: 90px;
}
.carousel-slide-dialog p {
max-width: initial;
}
}

Related

Media Query BreakPoint on mobile not working

I'm creating an email with the below breakpoints, but I'm having some difficulties with the breakpoints.
The breakpoint below is not working on mobile, actually I used this same breakpoints for another email and it was working perfectly.
<style style="" type="text/css">
body {
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
img {
border: 0 !important;
outline: 0 !important;
}
p {
margin: 0 !important;
padding: 0 !important;
}
table {
border-collapse: collapse;
mso-table-lspace: 0;
mso-table-rspace: 0;
}
td {
border-collapse: collapse;
mso-line-height-rule: exactly;
}
a {
border-collapse: collapse;
mso-line-height-rule: exactly;
}
span {
border-collapse: collapse;
mso-line-height-rule: exactly;
}
.ExternalClass * {
line-height: 100%;
}
span.MsoHyperlink {
mso-style-priority: 99;
color: inherit;
}
span.MsoHyperlinkFollowed {
mso-style-priority: 99;
color: inherit;
}
.em_defaultlink a {
color: inherit !important;
text-decoration: none !important;
}
#media only screen and (max-width: 4ii80px) {
table[class="em_wrapper"] {
width: 100% !important;
}
}
#media only screen and (max-width: 480px) {
table[class="em_main_table"] {
width: 100% !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_aside"] {
padding: 0 10px !important;
}
}
#media only screen and (max-width: 480px) {
br[class="em_hide"],
span[class="em_hide"],
table[class="em_hide"],
td[class="em_hide"] {
display: none !important;
}
}
#media only screen and (max-width: 480px) {
img[class="em_full_img"] {
width: 100% !important;
height: auto !important;
}
}
#media only screen and (max-width: 480px) {
img[class="em_full_img1"] {
width: 100% !important;
height: auto !important;
max-width: 100% !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_side"] {
width: 10px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_spc_20"] {
height: 20px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_gap_bottom"] {
padding-bottom: 20px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_height_25"] {
height: 25px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_f11"] {
font-size: 11px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_height_35"] {
height: 20px !important;
}
}
#media only screen and (max-width: 480px) {
td[class="em_text"] {
font-size: 18px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
table[class="em_wrapper"] {
width: 100% !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
table[class="em_main_table"] {
width: 100% !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_aside"] {
padding: 0 10px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
br[class="em_hide"],
span[class="em_hide"],
table[class="em_hide"],
td[class="em_hide"] {
display: none !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
img[class="em_full_img"] {
width: 100% !important;
height: auto !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
img[class="em_full_img1"] {
width: 100% !important;
height: auto !important;
max-width: 100% !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_side"] {
width: 10px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_spc_20"] {
height: 20px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_gap_bottom"] {
padding-bottom: 20px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_height_25"] {
height: 25px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_f11"] {
font-size: 11px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_height_35"] {
height: 20px !important;
}
}
#media only screen and (min-width: 481px) and (max-width: 599px) {
td[class="em_text"] {
font-size: 18px !important;
}
}
#media only screen and (max-width: 600px) {
.caption{
font-size: 20px !important;
color: red !important;
}
}
</style>
If you have mistakes like (max-width: 4ii80px) and certain constructions like [class="em_hide"], some email clients - particularly Gmail - will strip your entire <style> block. Use a CSS and HTML validator (there are plenty online), but ignore the warnings about deprecated code (HTML email uses a lot of deprecated code just fine).
Use https://www.caniemail.com/features/css-at-media/ to find out what you should expect.
Then also just use basic CSS selectors like .em_hide instead of [class="em_hide"].
I would also wrap the media queries in their own <style> block (yes you can have multiple), because some of the other things only apply to certain email clients, and Gmail doesn't like them. (For example Mso stuff only relates to Outlook desktop.)
The mistake was from the style tag
I typed instead of <style="" type="text/css">

Trouble with fixing search container margins on mobile

(some background, I'm a designer who's trying to learn how to code!)
I'm having trouble fixing the search input field surrounding area for mobile for https://www.agjeans.com. It's cut off at the top in mobile view. While in Chrome dev tools, I'm able to seemingly fix the issue, the reality is that when I input these code changes they seem to do nothing.
I've done a variety of code changes, such as
#media only screen and (max-width: 768px)
.header-search .mobile-search-active+.search-wrapper {
padding-bottom: 72px;
border: 0;
margin-top: 30px;
}
and have done
#media only screen and (max-width: 768px) {
.search-wrapper {
margin-top: 30px !important;
}
}
and also
.search-button-container.mobile-search-active {
margin-top: 30px;
}
As you can see, these resulting changes look great in dev tools, but do nothing when actually implementing the code. I've looked at the site on my own personal phone as well as in the browser, so the issue remains persistent.
Also, if I add something ridiculous (like specifying 300px margin-top for the header) it does show in the site, so I know it's just with this issue. What's the correct solution?
All this is done in the style.min.css file. This animation is the result of all the steps below - https://ibb.co/zJWnLbf.
Initially your selector #media only screen and (max-width: 768px) .header-search .mobile-search-active + .search-wrapper looks like this:
#media only screen and (max-width: 768px) {
.header-search .mobile-search-active + .search-wrapper {
padding-bottom: 72px;
border: 0;
}
}
You need to add a top: -37px. And now this selector should look like this:
#media only screen and (max-width: 768px) {
.header-search .mobile-search-active + .search-wrapper {
padding-bottom: 72px;
border: 0;
top: -37px;
}
}
Ok, now we need to correct the closing cross. To do this, you need to turn to the selector #media only screen and (max-width: 480px) and (min-width: 320px) .header-search .search-button.active looks like this:
#media only screen and (max-width: 480px) and (min-width: 320px) {
.header-search .search-button.active {
background: url(../images/close-x-button.svg) no-repeat;
background-size: 15px auto;
z-index: 2;
left: 10px;
top: -32px;
width: 15px;
height: 15px;
border: none;
padding: 0;
}
}
You need to add a top: 10px and remoeve a top: -32px. And now this selector should look like this:
#media only screen and (max-width: 480px) and (min-width: 320px) {
.header-search .search-button.active {
background: url(../images/close-x-button.svg) no-repeat;
background-size: 15px auto;
z-index: 2;
left: 10px;
top: 10px;
width: 15px;
height: 15px;
border: none;
padding: 0;
}
}
And the same top: 10px rule needs to be added for the #media only screen and (max-width: 768px) and (min-width: 370px) .header-search .search-button.active selector. As a result, it should look like this:
#media only screen and (max-width: 768px) and (min-width: 370px) {
.header-search .search-button.active {
background: url(../images/close-x-button.svg) no-repeat;
background-size: 15px auto;
z-index: 2;
top: 10px;
left: 20px;
width: 15px;
height: 15px;
border: none;
padding: 0;
}
}

Responsive iframe with varying aspect ratio content - have solution looking for better one

I have a requirement for a responsive iframe. I have found many solutions for embeding videos (and Bootstrap even has classes for this specific case) but I'm embeding a form which itself is responsive (This is a Global Payments / Realex Paymenmts HPP card paymemt form if anyone know it).
So, the aspect ration of the form changes based on its size and also what the user does - for example it gets longer to display error messages.
Also, as can be seen the initial content is the iframe is just "Please wait..." and the thoird party form is loaded via javascript.
I have modified the video embeding method by adding progressive media queries to increase padding as the device gets smaller and thus the form longer, to avoid scroll bars. It seems to work well, but there must be a more efficient/simple/elegant solution?
HTML
<div class='hpp_iframe_wrapper'>
<iframe class='hpp_iframe' id='realex_hpp_iframe' name='realex_hpp_iframe' srcdoc='<p>Please wait ...</p>'></iframe>
</div>
CSS
.hpp_iframe_wrapper {
position: relative;
overflow: hidden;
padding-top: 80%;
}
.hpp_iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
#media (max-width: 1000px) {
.hpp_iframe_wrapper {
padding-top: 90%;
}
}
#media (max-width: 900px) {
.hpp_iframe_wrapper {
padding-top: 100%;
}
}
#media (max-width: 800px) {
.hpp_iframe_wrapper {
padding-top: 130%;
}
}
#media (max-width: 700px) {
.hpp_iframe_wrapper {
padding-top: 145%;
}
}
#media (max-width: 600px) {
.hpp_iframe_wrapper {
padding-top: 160%;
}
}
#media (max-width: 500px) {
.hpp_iframe_wrapper {
padding-top: 185%;
}
}
#media (max-width: 450px) {
.hpp_iframe_wrapper {
padding-top: 200%;
}
}
#media (max-width: 400px) {
.hpp_iframe_wrapper {
padding-top: 220%;
}
}
#media (max-width: 360px) {
.hpp_iframe_wrapper {
padding-top: 240%;
}
}
#media (max-width: 340px) {
.hpp_iframe_wrapper {
padding-top: 260%;
}
}

Strange Bootstrap Container Breakpoint Behaviour

If I set the browser width to 1024px the following bootstrap container rule is being applied:
#media (min-width: 768px) {
.container {
width: 750px;
}
}
If I extend the browser width to 1092px then the following bootstrap container rule is being applied:
#media (min-width: 992px) {
.container {
width: 970px;
}
}
There are no other CSS rules applied to the container, just the standard bootstrap rules:
.container {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
}
Can anyone explain to me why a browser width of 1024px isn't getting the min-width: 992px rules applied to it?
I think you forget open close bracket { }
#media (min-width: 768px) {
.container {
width: 750px;
background: yellow;
}
}
#media (min-width: 992px) {
.container {
width: 970px;
background: red;
}
}

How can I place text on top of flexible images?

friends!
I`m trying to make a grid of flexible images that come in a row. I dont even need additional div properties for that, works fine as is
<div class="container_imggrid"> <img> </div>
Css
.container_imggrid img {
display: inline-block;
max-width: 25%;
height: auto;
}
But now i need to add text above my picture, Div with text should be flexible as well.
U can see what i mean at this page http://www.reebok.com/us. That big image with "start designing" sign is flexible until some point, as well as text above it.
I need similar Header properties for my grid elements, but cant position my text block properly.
Can you please help me? Maybe i need absolutely another grid basis for such features?
My interactive fiddle is here: https://jsfiddle.net/CapablancaYEAH/yr809ty8/
P.S. To make things more clear, let me re-phrase.
I need a flexible grid.
Each separate block of grid is Square DIV with image inside and centered header on top of image.
Image should be resized and fit accordingly to div`s width/height (browser window size change).
Header should remain centered with div after any browser window resize.
Just set position:relative to parent div and position:absolute with top and left 50% for h2 tag.
.container_banner{position:relative;}
.container_banner img{width:100%;height:auto;}
.container_banner h2{position: absolute;
right: 0;
width: 50%;
left: 0;
margin: 0 auto;
text-align: center;
top: 44%;}
.container_imggrid{width:25%;}
<div class="container">
<div class="container_banner">
<h2>Swimming</h2>
<img src="https://i.yapx.ru/JEvD.jpg" width="1000" height="300">
</div>
<div class="container_imggrid container_banner">
<h2>Swimming</h2>
<img src="https://i.yapx.ru/JEvC.jpg" width="500" height="500" alt="Подводное плавание">
</div>
</div>
Make sure your parent div width is same as your <img> tag with. It should be same otherwise you need to set your image in background inside the parent div.
Hope this will helpful for you.
Thanks.
Using position: relative (for parent) and position: absolute (for child)
https://jsfiddle.net/kaskull/yr809ty8/4/
You can use media queries at each stage to manipulate the text size at different screen sizes like:
#media only screen and (min-width: 360px){
.flx-text{
font-size:1em;
}
}
Example Fiddle (try resizing for effect):
JSFIDDLE
Snippet [Go full screen and resize for effect]:
.container_banner {
padding-bottom: 15px;
}
.container_banner img {
max-width: 100%;
height: auto;
}
.container_imggrid img {
display: inline-block;
max-width: 25%;
height: auto;
}
.container_imggrid h2 {
display: block;
position: fixed;
max-width: 50%;
}
#media only screen and (min-width: 360px) {
.flx-text {
font-size: 0.9rem
}
}
#media only screen and (min-width: 390px) {
.flx-text {
font-size: 1.0rem
}
}
#media only screen and (min-width: 420px) {
.flx-text {
font-size: 1.1rem
}
}
#media only screen and (min-width: 450px) {
.flx-text {
font-size: 1.2rem
}
}
#media only screen and (min-width: 480px) {
.flx-text {
font-size: 1.3rem
}
}
#media only screen and (min-width: 510px) {
.flx-text {
font-size: 1.4rem
}
}
#media only screen and (min-width: 540px) {
.flx-text {
font-size: 1.5rem
}
}
#media only screen and (min-width: 570px) {
.flx-text {
font-size: 1.6rem
}
}
#media only screen and (min-width: 600px) {
.flx-text {
font-size: 1.7rem
}
}
#media only screen and (min-width: 630px) {
.flx-text {
font-size: 1.8rem
}
}
#media only screen and (min-width: 660px) {
.flx-text {
font-size: 1.9rem
}
}
#media only screen and (min-width: 690px) {
.flx-text {
font-size: 2.0rem
}
}
#media only screen and (min-width: 720px) {
.flx-text {
font-size: 2.1rem
}
}
#media only screen and (min-width: 750px) {
.flx-text {
font-size: 2.2rem
}
}
#media only screen and (min-width: 780px) {
.flx-text {
font-size: 2.3rem
}
}
#media only screen and (min-width: 810px) {
.flx-text {
font-size: 2.4rem
}
}
#media only screen and (min-width: 840px) {
.flx-text {
font-size: 2.5rem
}
}
#media only screen and (min-width: 870px) {
.flx-text {
font-size: 2.6rem
}
}
#media only screen and (min-width: 900px) {
.flx-text {
font-size: 2.7rem
}
}
#media only screen and (min-width: 930px) {
.flx-text {
font-size: 2.8rem
}
}
#media only screen and (min-width: 960px) {
.flx-text {
font-size: 2.9rem
}
}
#media only screen and (max-width: 360px) {
.flx-text {
font-size: 0.8rem
}
}
<div class="container">
<div class="container_banner">
<img src="https://i.yapx.ru/JEvD.jpg" width="1000" height="300">
</div>
<div class="container_imggrid">
<h2 class="flx-text">Swimming</h2>
<img src="https://i.yapx.ru/JEvC.jpg" width="500" height="500" alt="Подводное плавание">
</div>
</div>
After all, I was able to figure out a solution. It uses a trick with
font-size: 0;
see https://jsfiddle.net/CapablancaYEAH/68aqv37b/