前提・実現したいこと
【HTML・CSS】のtableでスマホでは縦、パソコンでは横に表示したいです。
ここに質問の内容を詳しく書いてください。
@media (min-width : 600px)以降で、display:block;を無効にしても解除されず、うまく表示されません。@media (min-width : 600px)より後で、display:block;が解除できていないみたいなのですが、どうでしょうか。なにか解決策あればお願いいたします。
該当のソースコード
html
1<table class="form"> 2<tr> 3<th>お名前※</th> 4<td><input size="30" type="text" name="お名前" /> </td> 5</tr> 6<tr> 7<th>電話番号(半角)</th> 8<td><input size="30" type="text" name="電話番号" /></td> 9</tr> 10<tr> 11<th>Mail(半角)※</th> 12<td><input size="30" type="text" name="Email" /> </td> 13</tr> 14<tr> 15<th>お問い合わせ内容<br /></th> 16<td><textarea name="お問い合わせ内容" cols="50" rows="5"></textarea></td> 17</tr> 18</table>
css
1table.form{ 2 width:100%; 3} 4table.form th, 5table.form td { 6 width:100%; 7 display:block; 8 border:1px solid #ccc; 9 padding:10px; 10 box-sizing: border-box; 11} 12table.form th { 13 text-align: left; 14 font-weight:normal; 15 background:#efefef; 16 margin-top:10px; 17 border-bottom:0; 18} 19input[type="text"], 20textarea { 21 width:100%; 22 padding:5px; 23 font-size:120%; 24 display:block; 25 box-sizing: border-box; 26} 27input[type="submit"], 28input[type="reset"], { 29 display:block; 30 width:100%; 31 height:40px; 32 margin-top:20px; 33} 34 35 36 37@media (min-width : 600px) { 38table.form{ 39 width:100%; 40} 41table.form th, 42table.form td { 43 width:100%; 44 border:1px solid #ccc; 45 padding:10px; 46 box-sizing: border-box; 47} 48table.form th { 49 text-align: left; 50 font-weight:normal; 51 background:#efefef; 52 margin-top:10px; 53 border-bottom:0; 54} 55input[type="text"], 56textarea { 57 width:100%; 58 padding:5px; 59 font-size:120%; 60 box-sizing: border-box; 61} 62input[type="submit"], 63input[type="reset"], { 64 width:100%; 65 height:40px; 66 margin-top:20px; 67} 68} 69
試したこと
@media前後の違いは、display:block;があるかないかだけです。
@media (min-width : 600px)を (max-width : 600px)にかえて、前後逆にすると、うまく表示しました。じゃあ、(max-width : 600px)でしたらいいと思われるかもしれませんが、他のページに影響するので、できません。よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー