I would like to know what is the best way for making table data responsive in email ?
I use Ink by Zurb for making my responsive email and I would like to insert it a table data (like shopping card table). But I would like it responsive. My idea is to set 2 tables, one for desktop and another for mobile and hide either one or other depending on the size of the screen.
I have found many solutions for hiding something in email. But no one work in every webmail.
Do you have any idea ?
Thanks.
Based on your codepen you have a couple choices.
The first one is a simple solution, similar to what you already have on there. The second is a lot more difficult and complex - but will remove the need to have 2 separate data tables.
1.) Do a mobile table and a desktop table. Have the Mobile table display by default and use percentages with Max-Width to contain for gmail client. Then have media queries at your desktop break point (e.g. usually around 600px) that change it to display:none !important, etc. to hide the table on desktop. You then by default hide the desktop version. In gmail, using display:none doesnt work, in order to get it to work you need to use display:none !important, which makes inlining it pretty much useless. See a list below taken from here on css to use to hide in gmail. You then have the media query also change the desktop table to display, effectively replacing it. This does mean that on gmail web client, that the mobile table will display.
display: none;
font-size: 0;
max-height: 0;
line-height: 0;
padding: 0; (optional)
mso-hide: all; /* hide elements in Outlook 2007-2013 */ (optional)
2.) Your second option is to build a bunch of block tables that act as each row and the tds will stack on mobile with hidden tds for headers that display on desktop or mobile, etc. This can get very complex and very tenuous as a tiny change can break the whole thing. It would likely give you much better display across all clients, but in my opinion the first option is a much more efficient and sustainable.
I would suggest you take a look at this neat article:
display table explanation
Else you can try to use the display: flex property
Related
I'm trying to change the breakpoint of a website's header.
the theme I installed onto this website has the mobile header breaking at 1139px and below. I want to change it so that it breaks at the standard 1024px (ie 1023px)
website: https://www.vibrantrealestate.com.au/
normally i just go into the css and change the #media query to the width i want to, but this theme has quite a few #media querys with min-width: 1140px/max-width: 1139px when i searched in the stylesheet so i'm not exactly sure which one I should change. i've tried trying to change them individually through the wordpress customiser, however i'm still a bit stuck for ideas as it isn't changing the appearance. thanks
I would not modify the theme's original style rules, instead you want to override them.
Although not advisable, this could be as simple as making new #media rules placed at the very bottom of the theme's CSS file, so in theory they override the earlier rules (if you configure the new rules correctly).
However the best thing would be to create a child theme, with the original theme as the parent. This would ensure your changes are wholly separate from the original code; much cleaner/safer/more-organized.
In either case, you'll have to use your brain to setup the new rules so they fully override the originals. You may need to make use of the !important flag.
You could make an override that covers a slightly wider range, to make sure your aesthetic changes take hold. e.g. min-width: 1000px/max-width: 1200px; (if the original is min-width: 1140px/max-width: 1139px).
You can't avoid work when doing responsive optimization.
I am creating media queries for a page but I'm having a problem in getting them to break at exactly the points specified in my media queries.
For example I have:
#media all and (max-width:1000px) {
header nav ul.nav_items li a {
padding:15px 10px 15px;
}
}
But when I use Chrome and open the dev tools, and observe the viewport/width of the browser, the CSS rules take effect at somewhere around 1226px. Why aren't the CSS rules being applied at exactly 1000px?
Here is a jsfiddle of my HTML/CSS: https://jsfiddle.net/at68m0zp/
By moving the media query to the end of your CSS file, you will make it override the set values. The later something appears (and the more specific it gets) the more preference it receives. Because your query is at the start of the file, any changes to your header nav's display property later does not get applied. Please not that media queries do not increase specificity or get any special treatment, they just get ignored until they are in the range defined by them.
So there is probably a snippet later in your file with a max-width of, say, 1000px. Because it comes after your 900px one but the screen size makes both valid, the 1000px one takes effect.
I had a snippet with the changes but because you posted your entire HTML and CSS it is too long to post here. Trust me, it works if you move it to the end
326px difference is definately not 'inaccuracy'. Something is broken here big time. I might guess that you have more media queries and mistaken min-width max-width setups somewere.
The best to check what is actually going on:
Firefox - hit F12 (or open Dev Tools when on Mac)
Go to 'Style Editor' in Dev Tools top bar
Column on the right shows list of #media rules (breaking points)
Have fun and good luck with debug.
I'm using drupal (jollyness) theme and I am hosting a mock up site at seosolutions.london
I have been trying to see if there is a css work around to either "prevent my calendar displaying more than one month at a time" OR "to hide any extra months from view"
I have tried playing around with the widths of the various container divs (using chrome developer) but nothing seems to make a difference.
does anyone have any suggestions please?
Try adding this to your CSS file:
.cal-viewport { width: 220px !important; }
Although you should refrain from using !important in your CSS, it is needed in this case (as inline styles are being applied).
I have read in a few other posts that creating a tappable link for a phone number can be done with tel: in an anchor tag
I would like to implement this in a responsive website.. something like this:
Call Us! <span>(555) 555-5555</span>
(the span tag I plan to use to hide the phone# with CSS)
The idea is that on a desktop you will only see "Call Us! (555) 555-5555", but not be an actual link
But when we scale down to mobile, you will then see a stylized link that just says "Call Us!" that you can click.
I'm sure there is a way to accomplish this with JavaScript or JQuery... but is there anyway to accomplish this with CSS Media Queries?
Note: Visual styling is no problem.. just looking for a reasonable solution for the "switching" concept.
Thanks in advance!
There really isn't anything wrong with leaving the link on desktop computers. This would for example allow you to click the link to call via Skype or other VOIP program you might have installed.
If you still want to change the link, just create two of them. One that is shown for desktops, the other for mobiles.
You could create 2 links, one to show on desktop and one for mobile
OR
Use css to style the anchor with phone number in them to default cursor so it does not look like a link even when you hover. To complement this, you need to use js to disable the click action.
This is all assuming you can detect what device you are on reliably.
I think your best bet would be to add an ID to your anchor tag and through your media query you can hide it on the desktop version there no need for the span.
Then for your non anchor text hide that when you are scaled down through another ID in a media query.
TEL: 123-456-789
#media screen and (min-width: 600px) {
.tel-link {
color: #000 !important;
text-decoration: none !important;
}
}
This will display the phone number in plain black for the browsers over 600px wide ( so it doesn't look like a link ) even though it still has a link. I think it's ok because you can make a call from PC nowadays.
Based on my research, it seems that what I want to do is not possible, but in case something has changed, I wanted to check to see if anyone had come up with a way to do this.
I have a web app that generates reports for print based on user selections in the browser window. I have a custom header and footer that, when the report is printed from the browser, should be repeated on every printed page. It is not the browser header and footer I need, but rather the custom ones that I generate. Also, I don't think this is an issue of CSS and media types, but I am not a CSS expert. I have no issues getting the header and footer to print once, but I can't get them to print on each page. I have read that perhaps if I recreated my report pages using tables, and then used table head tags and CSS, that may work at least to get the header on each page. I have not had success with this yet, but I will try it again if it is the only option. A coworker suggested that I count lines in my php and manually put out the header and footer as required. I guess that is an option, but it just seems like there should be a way to do this that isn't so "brute force"!
The other caveat is that I have to support IE 6, so I suspect some of the CSS things I have tried are just not supported.
If anyone knows any way to do this, that would be great! If there isn't, I will have to rethink my approach.
Thanks in advance!
UPDATE (14 Dec 2011)
I made considerable progress with this issue, and using some of the info from the answers, I did produce reports that were usable, but never as nice or as professional as I wanted. Footers would tend to be not close enough to the bottom of the page, I had to do a lot of guess work and "brittle" calculations about how big text was going to be to decide on inserting page breaks, I could only support a restricted set of page formats, and any changes to the reports resulted in a cascade of code changes and yet more brittle calculations. There was always a scenario that broke some part of some report. We revisted the requirements, and are now generating reports as PDFs using TCPDF. The documentation is a bit opaque, and it takes some experimentation, but the results are far superior and now the reports appear as they should. I would say to anyone trying to do HTML reports from the browser, unless they are very simple, save yourself the frustration (as others told me here) and go with PDFs or something similar.
It can be done with tables -- and I know I'm going to risk a downvote by suggesting using tables for layout - but we are talking IE6 here which isn't known for its fantastic CSS support :-)
If you set a CSS style as follows:
thead { display: table-header-group; }
tfoot { display: table-footer-group; }
Then when you create your HTML, render your body as:
<body>
<table>
<thead><tr><td>Your header goes here</td></tr></thead>
<tfoot><tr><td>Your footer goes here</td></tr></tfoot>
<tbody>
<tr><td>
Page body in here -- as long as it needs to be
</td></tr>
</tbody>
</table>
</body>
Yes it's not good (tables vs CSS), it's not ideal, but (importantly for you) it does work on IE6. I can't comment on Firefox as I've not tested it there, but it should do the job. This will also handle differnt sized pages, differing font sizes, etc. so it should "just work".
If you want the header and footer to appear on printed media only, then use the #media parameters to do the right thing:
#media print {
thead { display: table-header-group; }
tfoot { display: table-footer-group; }
}
#media screen {
thead { display: none; }
tfoot { display: none; }
}
Note
As of July 2015, this will still only work in Firefox and IE. Webkit-based browsers (cf. Chrome, Safari) have long standing bugs in their issue trackers about this if anyone feels strongly enough to vote on them:
The comments below this question tell me this is now resolved in Chrome. I haven't checked myself :-)
The original bugs against Chrome (for reference) are:
https://bugs.webkit.org/show_bug.cgi?id=17205
https://code.google.com/p/chromium/issues/detail?id=24826
https://code.google.com/p/chromium/issues/detail?id=99124
This will work in some browsers, not not all. I don't think there is an elegant cross-browser solution
Include the print footer/header you want in divs on the page (in this example div id='printableFooter')
In the screen css file put:
#printableFooter {display: none;}
In the print css file:
#printableFooter {display: block; position: fixed; bottom: 0;}
I would suggest to divide the page in table, and add the header part to first row and the footer part to the last row. The contents of the rows between the first and last rows can be changed dynamically so you will get the constant header and footer at desired pages.
----------
ROW1 HEADER
----------
ROW2
Insert dynamic contents here
ROW N-1
----------
ROW N Footer
try to generate a (rtf | pdf) document for printing