I have a google maps Section on my website for my contact page. In my browser the css for the map is
<div class="googlemap" style="margin-left: 50px; margin-right: 50px;">
<iframe style="border: 0;" src="map" width="50%" height="600" allowfullscreen="allowfullscreen">
</iframe>
</div>
In a smarthphone view i get the half map and aligned in left as shown below.
Google maps on mobile
I want to apply CSS that makes my map responsive on mobile.
I try something like the following but it doesnt work
#media screen and (max-width: 600px) {
.googlemap{
//these are the ideal margins for my mobile view
margin-left: 10px;
margin-right: -350px;
}
How to set this properly working?
Note two things that you must account for in restyling your map component:
Inline Styles
Iframe Attributes
The only way to override inline-styles from a stylesheet is to use the important! keyword. Read up on specificity to understand what is going on and some ways to overcome it: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
You may also have to use the important! keyword to override the iframe width and height attributes.
I don't know what your expected final design should be, but you could do something like the following:
* {
box-sizing: border-box;
}
#media screen and (max-width: 600px) {
.googlemap {
margin: 10px !important;
}
.googlemap > iframe {
width: 100% !important;
height: auto !important;
min-height: calc(100vh - 20px);
}
}
<div class="googlemap" style="margin-left: 50px; margin-right: 50px;">
<iframe style="border: 0;background: gray;" src="map" width="50%" height="600" allowfullscreen="allowfullscreen"></iframe>
</div>
Related
I have a html code like this:
<div id="markContainer" class="maxW1000">
<div id="titleRow">
Title
</div>
<div class="card-box listPhotos">
<iframe id="mNote"
src="https://classlive.stume.net/mnote.html" frameborder="0">
</iframe>
</div>
</div>
The CSS is like this:
#titleRow{
background-color: #00a7d0;
height: 40px;
}
.listPhotos {
width: 100%;
cursor: pointer;
height: calc(100vh - 40px);
}
#mNote{
width: 100%;
height: 100%;
}
I chrome browser in desktop, it displays like this. The iframe has its own buttons like this:
But when I open by browser in Android or iPhone, it looks like this. It seems like it taller than the device screen and the last button is hidden out:
You can use below css or also use javascript for making your site responsive.
#media only screen and (min-width:363px) and (max-width:400px) {
#titleRow{
background-color: #00a7d0;
height: 40px;
}
set properties according your requirementt
The problem is inside iframe. You need to style the components inside the iframe
I want to include the logos of each of my portfolio pages wrapped to the right in the text. I was able to accomplish this on desktop using inline HTML to float it right:
<p><a href="link" style="padding: 0 0px; float: right;" src="img" alt=""
width="200" height="200" /></a></p>
<h4><strong>Amazin' Aces Pickleball</strong></h4>
Here is the link: http://matzniewski.com/my-work/amazin-aces/
This is what it looks like on mobile:
How can I get it so the logo sits on top of the title on mobile so they aren't scrunched together?
I figured I'm going to have to go into the CSS but I've been messing around with different commands within my
#media only screen and (max-width: 480px) {
and can't figure out how to get it right.
I am using Wordpress and SiteOrigin, if that's relevant.
Use Media Queries to adjust your float property.
.widget img {
height: auto
}
#media screen and (min-width:831px) {
.widget img {
float: right;
}
}
#media screen and (max-width:830px) {
.widget img {
float: none;
}
}
I have this html tag to put an arbitrary image on a page.
<img src="https://example.com/wp-content/uploads/....186.png" width="133" height="13" style="float:right; margin-right: 100px; margin-top: 40px;" />
However, I dont want this image on mobile. Can this be done?
It is better to be mobile first.
select class for your image. for example hide-mobile. then write these codes:
.hide-mobile
{
display: none;
}
#media only screen and (min-width: 500px) {
.hide-mobile
{
display: block;
}
}
You should take a look at media queries:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
To hide the image, you would need a media query with display:none, which is only included on a low resolution.
#media only screen and (max-width: 500px) {
img {
display: none;
}
}
EDIT: It is not a good idea to define your style inline. You should rather use a seperate css file or at least a <style> block in your header. This helps with controlling different scenarios and keep your styling consistent over multiple objects and pages.
I'm currently creating a responsive email template, and i have got to the testing stage and found out that Google remove any classes you add to your tables.
I have tried using an ID as well, but they strip that as well as any data-attributes I tried.
I read up about this alittle and came across a little trick to bypass this. I managed to get this to work, but not it seems to be broken again. This trick is as follows
<table id="container" lang="x-container" title="container" class="container" width="100%" cellpadding="0" cellspacing="0" style="max-width: 600px;margin: 0 auto;">
and the CSS would be
[title~=container] {
width: 100% !important;
}
but Google seems to strip that form my styling. Once i add * in front of the selector it stays in my css but my element doesnt seem to pick it up.
So my question is. What is the best way to target an element in gmail with media queries if you cant use ID or Class?
You can use the following:
* [summary~='fakeclassname'] {
styles: here;
}
"Summary" is one of the attributes that Gmail does not strip out. After it occurred to me what Gmail was actually doing to emails I found this article that breaks it down in detail:
http://freshinbox.com/blog/interactive-emails-in-gmail-using-css-attribute-selectors/
There are helpful links on that page that get deeper into Gmail-specific targeting.
EDIT: it appears Exact Target strips out the "summary" attribute in ET Send Preview. The "title" attribute works fine if you want it to look correct in both Gmail and ET Preview.
This approach seems to do the job for me currently:
Styles in <head> of your e-mail template (these are removed in Gmail, but do apply for other clients):
<style type="text/css">
/* Styles below are applied on all clients except Gmail */
/* Desktop */
div[id=tablet],
div[id=mobile]{
display: none;
}
/* Tablet */
#media only screen and (max-device-width: 1024px){
div[id=desktop],
div[id=mobile]{
display: none !important;
}
div[id=tablet]{
display: block !important;
font-size: 15px !important;
max-height: none !important;
overflow: visible !important;
}
}
/* Phone */
#media only screen and (max-device-width: 736px){
div[id=desktop],
div[id=tablet]{
display: none !important;
}
div[id=mobile]{
display: block !important;
font-size: 15px !important;
max-height: none !important;
overflow: visible !important;
}
}
</style>
HTML:
<body>
<div id="desktop">
[template for desktop]
</div>
<div id="tablet" style="font-size: 0; max-height: 0; overflow: hidden;">
[template for tablet]
</div>
<div id="phone" style="font-size: 0; max-height: 0; overflow: hidden;">
[template for phone]
</div>
</body>
I'm trying to build a responsive HTML email. I'm attempting to do something fairly simple but getting stuck and am starting to be convinced that I may need to approach it in a different way.
I want to show certain content if the user is on a mobile device, and hide it otherwise.
My first attempt looked like:
The CSS in the head:
#media (max-width: 420px) and (min-width: 100px) {
.mobile {
display:block !important;
}
}
The HTML:
<div class='mobile' style='display:none;'>
I'm only visible on mobile :)
</div>
This works beautifully for most mail clients but not with Gmail which does not support 'display:none' without an '!important'. But, adding the !important to the inline styles means that it will not display for mobile.
I've tried a few different things including messing with visibility/opacity (figured that would be a start in the right direction, but that didn't work at all) and trying to sneak around inline styles by attempting:
The CSS in the head:
.mobile {
display: none !important;
}
#media (max-width: 420px) and (min-width: 100px) {
#fix .mobile {
display:block !important;
}
}
The HTML:
<div id='fix'>
<div class='mobile' style='display:none;'>
I'm only visible on mobile :)
</div>
</div>
But that didn't work either. Seems like it would be a pretty common problem.
Any ideas how to get around this?
Ah the beauty of software development: we get to just keep trying until things work! Found a fix. It seems like there is more than one way to get around Gmail's display: none (!important on the inline style is not the only way). Here's what worked for me:
The CSS in the head:
.mobile {
display: none;
font-size: 0;
max-height: 0;
line-height: 0;
padding: 0;
}
#media (max-width: 420px) and (min-width: 100px) {
.mobile {
display:block !important;
line-height: 1.5 !important;
max-height: none !important;
}
}
The HTML:
<div class='mobile' style='display:none;font-size: 0; max-height: 0; line-height: 0; padding: 0;'>
I'm only visible on mobile :)
</div>
How about using:
<div class="mobile" style="width:0; overflow:hidden;float:left; display:none"></div>