Trying to make a border-based button go full-width on small screens. Needs to work via CSS and HTML because this is for an email which can't use JS.
Any ideas?
Tried using media queries but it didnt work.
P.S. Border buttons are described here: https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design
.container {
width: 100%;
height: 300px;
background-color: #000000;
}
.link-button {
font-size: 16px;
font-family: Helvetica, Arial, sans-serif;
color: #ffffff;
text-decoration: none;
border-radius: 20px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
background-color: #EB7035;
border-top: 12px solid #EB7035;
border-bottom: 12px solid #EB7035;
border-right: 18px solid #EB7035;
border-left: 18px solid #EB7035;
display: inline-block;
}
#media only screen and (max-width: 480px) {
.inner-table {
width: 100%;
}
}
<div class="container">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="outer-table">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="inner-table">
<tr>
<td>
<a class="link-button" href="http://google.com" target="_blank">I am a button</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
Try to add min-width for the smaller screens
For anyone else, the answer is to set the .link-button class as a block instead of inline-block.
.inner-table {
text-align: center;
}
.link-button {
font-size: 16px;
font-family: Helvetica, Arial, sans-serif;
color: #ffffff;
text-decoration: none;
border-radius: 20px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
background-color: #EB7035;
border-top: 12px solid #EB7035;
border-bottom: 12px solid #EB7035;
border-right: 18px solid #EB7035;
border-left: 18px solid #EB7035;
display: inline-block;
}
#media screen and (max-width: 480px) {
.link-button {
display: block !important;
}
}
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="outer-table">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="inner-table" width="100%" >
<tr>
<td>
<a class="link-button" href="http://google.com" target="_blank">I am a button</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
Thanks to #CBroe who provided this answer in the comments.
Related
This is my code
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="font-size:40px;line-height:2px;color:red;">◖</td>
<td style="width:80px;height:30px;background-color:red;"></td>
<td style="font-size:40px;line-height:2px;color:red;">◗</td>
</tr>
</table>
Fiddle Example
What I want to do is to appear my table content as the div below ( with border radius )
<div style="width:120px;height:30px;background-color:red;border-radius:50px;"></div>
I have to do it with table like this because this code will use in html email for Outlook Desktop client which doesn't support border-radius .
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<div style="padding: 0;
margin: 0;
font-size: 40px;
line-height: 2px;
color: red;
background-image: url(http://freshcodelabel.com/images/red-half-circle.png);
background-repeat:no-repeat;
transform: rotate(180deg);
height: 186px;
width:90px;
display:inline-block;
">
</div>
<div style="width: 212px;height: 179px;background-color:#c60000;display:inline-block;"></div>
<div style="
padding: 0;
margin: 0;
font-size: 40px;
line-height: 2px;
color: red;
background-image: url(http://freshcodelabel.com/images/red-half-circle.png);
height: 186px;
background-repeat:no-repeat;
width:90px;
display:inline-block;
background-position: 0px 7px;
"></div>
</tr>
</table>
JSFiddle
Use images instead of characters.
Completely based on div.
div.my-button{
padding: 12px 18px 12px 18px;
border: 1px solid #e9703e;
background-color: #EB7035;
border-radius: 10px;
font-size: 16px;
margin-top: 20px;
width: 119px;
}
div.my-button a{
font-family: Helvetica, Arial, sans-serif;
color: #ffffff;
text-decoration: none;
}
<div class="my-button">
I am a button →
</div>
I am having issues with certain styles not showing correctly in browsers for tables that I created. Specifically the class I created .rowB background color not showing as well as the right side border that I created for class cellBrdrRght.
#charset "UTF-8";
/* CSS Document */
/* info charts */
td{
vertical-align: middle;
}
.chartHeader{
background-color: #115967!important;
color: #fff;
text-align: center;
font-weight: bold;
}
.rowA{
background-color: #d0d0d0!important;
color: #4b4b4b;
.rowB{
background-color: #666666!important;
color: #fff;
}
.cellBrdrRght {
border-style: solid!important;
border-width: 0px 1px 0px 0px!important;
border-color: white!important;
}
.cellnoBrd {
border-style: none;
}
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967!important;
color: #fff;
text-align: left;
colspan: 3;
a:sideBar {
background-color: #115967!important;
padding: 25px 50px 75px 100px;
color: #fff;
}
<link href="http://benefitsatbenefitelect.com/new/wp-content/styles/other-styles.css" rel="stylesheet" type="text/css">
<div style="overflow-x: auto;">
<table>
<tbody>
<tr class="chartHeader">
<td class="cellBrdrRght">Plan Benefits</td>
<td class="cellnoBrd" colspan="2">Current Benefits</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght">Description</td>
<td class="cellBrdrRght">PPO</td>
<td class="cellnoBrd">HDHP</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Deductible</b> In/Out-of-Network & 2x Family</td>
<td class="cellBrdrRght">$1,250/$2,250**</td>
<td class="cellnoBrd">$3,000/$6,000**</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght" style="text-align:left;"><b>Coinsurance</b> In/Out-of-Network</td>
<td class="cellBrdrRght">Alaska Plan 20%/20%<br> Non-Alaska Plan 20%/40%</td>
<td class="cellnoBrd">Alaska Plan 20%/20%<br> Non-Alaska Plan 20%/40%</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Out-of-Pocket Maximum</b> In/Out-of-Network & 2x Family</td>
<td class="cellBrdrRght">$5,000/$10,000</td>
<td class="cellnoBrd">$5,000/$10,000</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght" style="text-align:left;"><b>Primary/Specialist Office</b></td>
<td class="cellBrdrRght">$30 PCP/$40 Specialist</td>
<td class="cellnoBrd">Alaska Plan*: PCP 20%/20% Specialist 20%/20%<br> Non-Alaska Plan*: PCP 20%/40% Specialist 20%/40%</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Retail Prescriptions</b>Generic/Preferred/Non-Preferred</td>
<td class="cellBrdrRght">$20/$45/$60</td>
<td class="cellnoBrd">20%*</td>
</tr>
<tr class="tableFooter">
<td colspan="3">*After Deductible is met **Individuals in Family Tier need only meet individual deductible vs. family deductible</td>
</tr>
</tbody>
</table>
<hr/>
</div>
web page:
http://benefitsatbenefitelect.com/new/index.php/portfolio-item/dark-places/
css file:
http://benefitsatbenefitelect.com/new/wp-content/styles/other-styles.css
#charset "UTF-8";
/* CSS Document */
/* info charts */
td{
vertical-align: middle;
}
.chartHeader{
background-color: #115967 !important;
color: #fff;
text-align: center;
font-weight: bold;
}
.rowA{
background-color: #d0d0d0 !important;
color: #4b4b4b;
}
.rowB{
background-color: #666666 !important;
color: #fff;
}
.cellBrdrRght {
border-style: solid !important;
border-width: 0px 1px 0px 0px !important;
border-color: white !important;
}
.cellnoBrd {
border-style: none;
}
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967 !important;
color: #fff;
text-align: left;
colspan: 3;
}
a:sideBar {
background-color: #115967 !important;
padding: 25px 50px 75px 100px;
color: #fff;
}
Change this your .rowA & .tableFooter is not closed properly in {}...
You missed closing tags in .rowA:
.rowA{
background-color: #d0d0d0!important;
color: #4b4b4b;
}
and in .tableFooter:
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967!important;
color: #fff;
text-align: left;
colspan: 3;
}
Try this and it should properly work
How can I make these buttons all align left with about a 3px space between them and adjust their own size based on how much text is put into them?
Unfortunately I don't have access to my own CSS (someone charges hundreds for this privilege). I've been trying for hours but just can't figure it out:
<br>
<style>
.mylink {
padding: 10px 35px;
background-color: #434343;
color: #fffFFF;
text-transform: uppercase;
letter-spacing: -.2px;
text-decoration: none;
font-family: helvetica,arial,sans-serif;
border-radius: 5px;
font-size: 12px;
width: 100%
}
.mylink:hover {
background-color: #ff0000; color: #fffFFF;
}
</style>
<table width="100%">
<tbody>
<tr>
<td width="0%" style="text-align: left;">
<a class="mylink" href="http://www.zzz.com/">ZZZ</a>
</td><td width="0%" style="text-align: left;">
<a class="mylink" href="http://www.aaa.com/">AAA</a>
</td><td width="0%" style="text-align: left;">
<a class="mylink" href="http://www.FFF.com/">FFF</a>
</td>
</td>
</tr>
</tbody>
</table>
Assuming that your other CSS is working by putting it inline (like you have put it), this should work, though a little hacky (floating cells and rows is ... unusual). I'd get rid of the table altogether if the effect here is what you want:
<style type="text/css">
.mylink {
padding: 10px 35px;
background-color: #434343;
color: #fffFFF;
text-transform: uppercase;
letter-spacing: -.2px;
text-decoration: none;
font-family: helvetica,arial,sans-serif;
border-radius: 5px;
font-size: 12px;
float:left;
}
.mylink:hover {
background-color: #ff0000; color: #fffFFF;
}
tr, td {
float:left;
padding:0;
}
</style>
<table>
<tbody>
<tr>
<td>
<a class="mylink" href="http://www.zzz.com/">ZZZZZZZZ</a>
</td>
<td>
<a class="mylink" href="http://www.aaa.com/">AAA</a>
</td>
<td>
<a class="mylink" href="http://www.FFF.com/">FFF</a>
</td><!-- Remove the extra </td> here. -->
</tr>
</tbody>
</table>
What this should look like if it works: https://jsfiddle.net/cmhqr3dg/
I believe this is the effect you are going for.
<br>
<style>
.mylink {
padding: 10px 35px;
background-color: #434343;
color: #fffFFF;
text-transform: uppercase;
letter-spacing: -.2px;
text-decoration: none;
font-family: helvetica,arial,sans-serif;
border-radius: 5px;
font-size: 12px;
width: 100%
}
.mylink:hover {
background-color: #ff0000; color: #fffFFF;
}
td {
float: left;
margin: 0 3px;
}
</style>
<table width="100%">
<tbody>
<tr>
<td>
<a class="mylink" href="http://www.zzz.com/">ZZZZZZZZZZ</a>
</td>
<td>
<a class="mylink" href="http://www.aaa.com/">AAAAAAAAAAAAAAAAAAAAA</a>
</td>
<td>
<a class="mylink" href="http://www.FFF.com/">FFF</a>
</td>
</td>
</tr>
</tbody>
</table>
I removed the style tags from the "td" elements and added the following into the "style" tags
td {
float: left;
margin: 0 3px;
}
I would like to put CSS buttons into several tables. Ideally, each button should fill the corresponding table cell. This presents a problem because if I hard-code the button width in CSS, I would need a separate class for each table dimension.
Is there a way to have the buttons fit into the table cells?
HTML:
<center>
<table border="1" width="90%" class="buttons">
<tr>
<td width="25%">Link1 goes here</td>
<td width="25%">Link2<br>goes<br>here</td>
<td width="25%">Link3<br>goes<br>here</td>
<td width="25%">Link4<br>goes<br>here</td>
</tr>
</table>
<p>
<table border="1" width="90%" class="buttons">
<tr>
<td width="20%">Link1 goes here</td>
<td width="20%">Link2<br>goes<br>here</td>
<td width="20%">Link3<br>goes<br>here</td>
<td width="20%">Link4<br>goes<br>here</td>
<td width="20%">Link5<br>goes<br>here</td>
</table>
</center>
CSS:
.buttons
{
overflow:auto;
text-align: center;
font-size: 1.0em;
font-weight: bold;
line-height: 200%;
}
.buttons a
{
display: inline-block;
width: 18em;
height: 6em;
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
clear:right;
float:right;
}
.buttons a:active
{
box-shadow: 1px 1px 0px #888888;
}
Play with the code:
http://codepen.io/anon/pen/bIEtC
You should try to set height and width 100%. Like this:
.buttons a
{
display: inline-block;
width: 100%; /* set to 100% */
height: 100%; /* set to 100% */
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
clear:right;
float:right;
}
Try not to hard code CSS into the HTML... it leads to a mess of trouble!
Taking the inline styling out of the html seems to fix most problems. Then, just like #ArmanVirdi said, add the width and the height of the link to be 100%.
The <center> tags don't seem to be doing anything, so those are removed in the below HTML, as well as an unclosed <p> tag.
HTML
<table class="buttons width-25">
<tr>
<td>Link1 goes here
</td>
<td>Link2<br>goes<br>here
</td>
<td>Link3<br>goes<br>here
</td>
<td>Link4<br>goes<br>here
</td>
</tr>
</table>
<table class="buttons width-20">
<tr>
<td>Link1 goes here
</td>
<td>Link2<br>goes<br>here
</td>
<td>Link3<br>goes<br>here
</td>
<td>Link4<br>goes<br>here
</td>
<td>Link5<br>goes<br>here
</td>
</table>
CSS
table {
width: 100%;
}
.width-20 td {
width: 20%;
}
.width-25 td {
width: 25%;
}
.buttons {
text-align: center;
font-size: 1.0em;
font-weight: bold;
line-height: 200%;
}
.buttons a {
display: inline-block;
height: 100%;
width: 100%;
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
}
.buttons a:active {
box-shadow: 1px 1px 0px #888888;
}
JSFiddle for reference
Add to .buttons:
width:0;
Resut:
I am developing a newsletter which should work on Outlook 2007 iPhone and iPad.
Ideally I would like to have links in the footer which are underlined but iPad and iPhone add their blue underline automatically to any link. And I can't get rid of it in any way (I googled already and read at least 10 different articles about this problematic)
Can someone please help me understanding what I do wrong?
I tried with lists but I can't get them on the same line anymore.
This is my code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!--[if gte mso 9]>
<style _tmplitem="50" >
.article-content ol, .article-content ul {
margin: 0 0 0 24px;
padding: 0;
list-style-position: inside;
}
</style>
<![endif]-->
<style type="text/css">
#media screen and (max-width: 610px) {
a[class=no-underline]{text-decoration:none;color:#00FF00}
}
.l-footer a {
color: #b2b2b2 !important; text-decoration: underline;
}
.l-footer a:link {
color: #b2b2b2 !important; text-decoration: underline;
}
.l-footer a:visited {
color: #b2b2b2; text-decoration: underline;
}
.l-footer a:hover {
color: #b2b2b2; text-decoration: underline;
}
.l-footer a:active {
color: #b2b2b2;text-decoration: underline;
}
</style>
</head>
<body>
<table id="background-table" border="0" cellpadding="0" cellspacing="0" width="100%" style="letter-spacing: -0.01em; border-collapse: collapse; font-family: arial; text-align: left; margin: 0px; padding: 0px; border: 0px;">
<tbody style="margin: 0px; padding: 0px; border: 0px;">
<tr>
<td align="center" bgcolor="#FFFFFF" style="color: #6f6f6f; border: #6f6f6f;">
<table class="w600 l-content-table" border="0" cellpadding="0" cellspacing="0" width="600" style="letter-spacing: -0.01em; border-collapse: collapse; font-family: arial; text-align: left; margin: 0px; padding: 0px; border: 0px;">
<tbody style="margin: 0px; padding: 0px; border: 0px;">
<tr>
<td class="w600" height="55" width="600" style="color: #6f6f6f; border: #6f6f6f;">
<table class="l-footer" border="0" cellpadding="0" cellspacing="0" style="letter-spacing: -0.01em; border-collapse: collapse; font-family: arial; text-align: left; margin: 0px; padding: 0px; border: 0px;">
<tbody style="margin: 0px; padding: 0px; border: 0px;">
<tr>
<td width="400" style="color: #6f6f6f; border: #6f6f6f;">
<table class="small-font" style="letter-spacing: -0.01em; border-collapse: collapse; font-family: arial; text-align: left; font-size: 12px; color: #b2b2b2 !important; text-transform: uppercase; margin: 0px; padding: 0px; border: 0px;">
<tbody style="margin: 0px; padding: 0px; border: 0px;">
<tr>
<td class="no-underline" class='is-last' style="letter-spacing: 0; padding-right: 12px; ">
<font style=' color: #b2b2b2;'>
<a href="http://www.lyra.net/fabio" target="blank" style="line-height: inherit; margin: 0px; padding: 0px; border: 0px;color: #b2b2b2;">
Responsibles
</a>
</font>
</td>
<td class="no-underline" class='is-last' style="letter-spacing: 0; padding-right: 12px; padding-left: 12px; border-left: 1px solid #b2b2b2;">
<font style=' color: #b2b2b2;'>
<a href="http://www.lyra.net/fabio" target="blank" style="line-height: inherit; margin: 0px; padding: 0px; border: 0px;color: #b2b2b2;">
Disclaimer
</a>
</font>
</td>
<td class="no-underline" class='is-last' style="letter-spacing: 0; padding-right: 12px; padding-left: 12px; border-left: 1px solid #b2b2b2;">
<font style=' color: #b2b2b2;'>
<a href="http://www.lyra.net/fabio" target="blank" style="line-height: inherit; margin: 0px; padding: 0px; border: 0px;color: #b2b2b2;">
Feedback
</a>
</font>
</td>
<td class="no-underline" class='is-last' style="letter-spacing: 0; padding-right: 12px; padding-left: 12px; border-left: 1px solid #b2b2b2;">
<font style=' color: #b2b2b2;'>
<a href="http://www.lyra.net/fabio" target="blank" style="line-height: inherit; margin: 0px; padding: 0px; border: 0px;color: #b2b2b2;">
RSS feeds
</a>
</font>
</td>
</tr>
</tbody>
</table>
</td>
<td width="210" align="right" style="color: #6f6f6f; border: #6f6f6f;">
<table class="small-font" style="letter-spacing: -0.01em; border-collapse: collapse; font-family: arial; text-align: left; font-size: 12px; color: #b2b2b2 !important; text-transform: uppercase; margin: 0px; padding: 0px; border: 0px;">
<tbody style="margin: 0px; padding: 0px; border: 0px;">
<tr>
<td class="is-first" style="color: #6f6f6f;letter-spacing: 0; padding: 0px; border: 0px">
<span style="color: #b2b2b2; line-height: inherit; margin: 0px; padding: 0px; border: 0px;">
© 2013
</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- block footer ends -->
</td>
</tr>
</tbody>
</table>
</body>
</html>
To test my code I send the HTML page as email from IE8
So far, the only solution I found is including the links in a single-element unordered list. This will ensure that the right underline color is applied also on iPhone.
<td style="letter-spacing: 0; border-left: 1px solid #b2b2b2;" width="120">
<ul style='list-style:none;' class="list">
<li class="plus last" style='margin-left:8px; border-top:0px;border-bottom:0px;'>
<font style="font-family: arial, helvetica, sans-serif;font-size: 11px;color: #ffffff;">
<a href="http://www.test.com" target='blank'>Rss Feeds</a>
</font>
</li>
</ul>
</td>
and this is the style
.list {
list-style:none;
margin:0px 0 0px 0px;
padding:0;
}
li.plus {
display:block;
margin:0px;
padding: 0px 0px 0px 0px;
text-decoration:none;
font-size: 12px;
}
li.plus a{
padding-left: 8px;
padding-right: 8px;
}
li.last a{
padding-right: 0px;
}
li.first a{
padding-left: 0px;
}
a:link {
color:#b2b2b2;;
text-decoration:underline;
}
a:visited {
color:#b2b2b2;;
text-decoration:none;
}
a:hover {
color:#b2b2b2;;
text-decoration:underline;
}
a:active {
color:#b2b2b2;;
text-decoration:none;
}
Just add this in your head section of the page
<style type=”text/css”>
.appleLinks a {color:#000000; text-decoration: none;}
.appleLinksWhite a {color:#ffffff; text-decoration: none;}
</style>
and it will stop links appearing blue in iOS and instead make them white. Just change the colour to what you require.
You can also throw plain <span> tags in between all text that would be turned into an unstyled link in outlook / gmail / ios, for example-
call 1 - 55<span>5 - 314 - 5</span>678
25 L Str<span>eet, Bosto</span>n MA 11385