2017-08-04 13 views
-1

小さな画面でボーダーベースのボタンを全幅にしようとしています。これはJSを使用できない電子メール用であるため、CSSとHTMLを介して作業する必要があります。小さな画面で表のボタンを全幅にする

アイデア?

メディアクエリを使用しようとしましたが、動作しませんでした。

P.S.ボーダーボタンがここで説明されています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>

+0

小さな画面ではボタンを100%にしていませんでした – inarilo

+0

異なる解像度で本当に別の動作が必要ですか?つまり、あなたは誰のためにもそれを広げたり、モバイルのためにそのまま残したりすることができます。 – Anarion

+0

代わりにボーダートリックを使わずに 'button'や' a'を使っていないのはなぜですか? –

答えて

0

分間幅を追加しようと、答えはよう.link-ボタンクラスを設定することですブロックはインラインブロックではなくブロックです。

.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>

コメントでこの回答を提供@CBroeに感謝します。

0

は誰のために小さな画面

+0

こんにちは@achraflakhdarですので、例としていくつかのコードを提供してください。 –

関連する問題