テーブルのtext-alignがきかない(IE7)

このQ&Aのポイント
  • テーブルのtext-alignがIE7で適用されない問題に困っています。
  • セル内のテキストを中央寄せにしたいのですが、左寄せになってしまいます。
  • さらに、テキストに対して十分なwidthがあるのに、途中で折り返されてしまう問題もあります。
回答を見る
  • ベストアンサー

テーブルのtext-alignがきかない(IE7)

お世話になります。初心者ですが、アドバイスいただけると助かります。 宜しくお願いします。 セル内のテキストを中央寄せにしたいのですが、 IE7では、下記のソースだと適用されないで困っています。(左寄せになる) (さらに、テキストに対して十分なwidthがあるのに、途中で折り返されて2行になってしまう) Safari、Firefox、Opera(いずれもMac)はOKでした。 例えば... ●●●●●● とセルの中に表示したいのに、 ●●●● ●● と途中で折り返されてしまう、(widthは余裕があります) CSS th,td.A{ width:30px; height:35px; text-align:center; } HTML <table> <tr> <td class="A"> ●●●●●●</td> </tr> </table>

noname#101548
noname#101548
  • HTML
  • 回答数3
  • ありがとう数3

質問者が選んだベストアンサー

  • ベストアンサー
  • asapinya
  • ベストアンサー率36% (40/109)
回答No.1

CSS中の width:30px; 狭すぎませんか? 問題なければこの1行を削除してみてください。

noname#101548
質問者

補足

ありがとうございます! できました!!

その他の回答 (2)

  • SAYKA
  • ベストアンサー率34% (944/2776)
回答No.3

折り返される = 幅が足りない(or余裕がない) とりあえずnowrapじゃないかな。

noname#101548
質問者

お礼

ありがとうございます! できました!!

  • ORUKA1951
  • ベストアンサー率45% (5062/11036)
回答No.2

[問題点] セル幅はpxでしていしてあると、ユーザーが視覚弱者でフォントのサイズを変えて閲覧すると折り返されます。ブラウザでCtrl++ないしCtrl+スクロールで拡大してごらん。 IEでは、初期設定でのpaddingが違うのでは? CSS・・・・td,th.A{padding:0.2em;width:10em;text-align:center;} (アドバイス)  class="A"なんてデザインのためだけのclassなんて使わず、セレクタをうまく使ったり、クラス名を適切に設定して、セルを特定しましょう。

noname#101548
質問者

補足

ありがとうございます! できました!!

関連するQ&A

  • CSSを使ってテーブルでセル全体をリンクしたい

    CSSを使ってテーブルでセル全体をリンクしたい CSSを使ってテーブルでセル全体をリンクしたい・・・と思っています。 4つのセル?を横並びにして(2段目は説明書き)、一つ一つ違うところに飛べるようにしたいのですけど、文字だけしかリンクできません。。。 block要素?を使うらしい?ということはわかったのですが、テーブル要素と組み合わせて使う場合どうしたらいいのでしょう? 色々やってみたのですが、セルが縦並べになってしまったりメインのcolorがなくなってしまったり、形が大幅に崩れたりしてしまいました。 ホームページ作りもCSSも初めてなので、なにをどうしたらよいか教えていただけると嬉しいです ソースをのっけておきます <cssの方> table#table-01 { width: 600px; border: 0px #E3E3E3 solid; border-collapse: separate; border-spacing: 20px 0; } table#table-01 th { width: 130px; height: 70px; padding: 5px; border: #E3E3E3 solid; border-width: 1px 0 0 1px; background: #F5F5F5; font-weight: bold; line-height: 120%; text-align: center; } table#table-01 td { vertical-align: top; padding: 1px 3px 20px 0; border: 0px #E3E3E3 solid; border-width: 0; text-align: center; } <htmlの方> <table id="table-01" cellspacing="20px"> <tr><th>●●●●</th><th>▲▲▲</th><th>■■■</th><th>○○○</th></tr> <tr><td>●の説明</td><td>▲の説明</td><td>■の説明</td><td>○の説明</td></tr> よろしくお願いします

    • ベストアンサー
    • HTML
  • safariとfirefoxとでテーブルレイアウトが変わってしまい、原因がわからずに困っています。

    safariとfirefoxとでテーブルレイアウトが変わってしまい、 原因がわからずに困っています。 下記のタグでテーブルを表示したいのですが、 safariでは私が頭の中で描いていた通りのレイアウトになるのですが firefoxで開くとボックスが横に伸びてしまいレイアウトが変わってしまいます。まだ素人なので原因がまったくわからず困っています。 どなたかアドバイスを頂ければ幸いです。 <style type="text/css"> marguee { background:#000000; color:#ff6699; padding:5px 0; } .profile th{ background:#fff0ff; font:10px Verdana; color:#666666; text-align:right; padding:5px; } .profile td{ background:#ffffff; font:10px Verdana; color:#333333; padding:5px; } </style> <body bgcolor="000000"> <!-- TEMPLATE START --> <div class="profile"> <div align="center"> <table bgcolor="#000000" cellspacing="1" cellpadding="0"> <tr> <td colspan="2" style="padding:0"> <marquee behavior="alternate">Biography</marquee></td> </tr> <tr> <th>Name</th> <td width="300">テキスト</td> </tr> <tr> <th>DOB</th> <td width="300">テキスト</td> </tr> <tr> <th>Height</th> <td width="300">テキスト</td> </tr> <tr> <th>POB</th> <td width="300">テキスト</td> </tr> <tr> <th>Blood Type</th> <td width="300">テキスト</td> </tr> <tr> <td colspan="2" style="padding:0"> <marquee behavior="alternate">Biography</marquee></td> </tr> </table> </div> <!-- TEMPLATE END --> </body> </html>

  • IEのテーブル表示の不具合でしょうか・・・?

    IEで正しく表示されているものが、別のページへ行って「戻る」ボタンを押すと、テーブルの表示が崩れてしまいます。 2列のテーブルの右側の部分が左側にかぶって表示されてしまうのです。 参考までにその部分のソースを以下に記述します。 何か気になる点などお気づきになられたら教えてください。 <table width="320" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200"> <table width="200" border="0" cellspacing="0" cellpadding="5"> <tr> <td class="px12"> ・<a href=>あああああ</a><br> ・<a href=>いいいいい</a><br> ・<a href=>ううううう</a><br> <hr width="160" size="1" noshade align="left"> ・<a href=>えええええ</a><br> <hr width="160" size="1" noshade align="left"> ・<a href=>おおおおお</a><br> <hr width="160" size="1" noshade align="left"> </td> </tr> </table> </td> ※以下から左側のテキストにかぶって表示されてしまいます。 <td width="120"><a href=><img src="images/画像.gif" width="120" heigt="180" border="0"></a><br> <table width="120" border="0" cellspacing="2" cellpadding="0"> <tr> <td valign="top"><img src="images/矢印画像.gif" width="11" height="11" border="0"></td> <td class="px12"><a href=>テキストテキストテキスト</a></td> </tr> </table> </td> </tr> </table> 以下が私の環境です。 WindowsXP(HomeEdition)・SP2インストール済・IE6 よろしくお願いします。

  • cssでテーブルの位置を設定するには?

    <table border="1" align="left">でテーブルの位置を競ってすることはできたのですが スタイルシートで行いたいです。 そもそも他のテーブルはすべて中央に寄せたいため、 table { margin-left: auto; margin-right: auto; } としています。 そのうえで、任意のテーブルのみ左に寄せて表示したいので table.test { align:left; } としたのですが、うまくいきません。 ---------------------------------------------------------- <html> <head> <title>test</title> <STYLE type="text/css"> table { margin-left: auto; margin-right: auto; width: 40%; } table.test { width: 80%; align:left; } </STYLE> </head> <body> <table border="1"> <tr><th>見出</th><th>見出</th></tr> <tr><td>セル</td><td>セル</td></tr> </table> <br><br><br> <table border="1" align="left"> <tr><th>見出</th><th>見出</th></tr> <tr><td>セル</td><td>セル</td></tr> </table> <br><br><br> <table border="1" class="test"> <tr><th>見出</th><th>見出</th></tr> <tr><td>セル</td><td>セル</td></tr> </table> </body> </html> ----------------------------------------------------- このコードだと、 table.test { width: 80%; align:left; } の、 width: 80%; の部分は認識されるようですが、align:left;は無視されます。 スタイルシートでテーブルの位置を設定する方法をご教授ください。

    • 締切済み
    • CSS
  • css テーブルについて

    よろしくお願いします。 2だけを300pxと100pxに2分割にできないでしょうか。 <div class="aa"> <table> <tr> <th>1</th> <td>2</td> </tr> <tr> <th>1</th> <td>1</td> </tr> </table> </div> .aa table { width: 500px; height: 100px; border: 1px #000000 solid; border-collapse: collapse; } .aa th { width: 100px; border: 1px #000000 solid; } .aa td { width: 400px; border: 1px #000000 solid; }

    • ベストアンサー
    • CSS
  • テーブルのテーブルの間に間ができるのでしょうか?

    はじめまして、超html初心者のものです。 なぜ同じようテーブルを3つ書いているのに一番上のテーブルと真ん中のテーブルの間が開いてしまっているのかがわかりません。 あと、一番上のテーブルの-から先をもう少し左に寄せることもうまくいきません。 なにかアドバイスをよろしくお願いします。 ↓これがソースです。 <html> <head><title>test</title> </head> <form> <table border=1 cellspacing=0 cellpadding=2 width=760> <tr> <th width=95 height=30 align="right">日付け:</th> <td width=284> <input type="text"><input type="button"> </td> <td>&nbsp;-&nbsp;</td> <td><input type="text"><input type="button"></td> </tr> </table> <table border=1 cellspacing=0 cellpadding=2 width=760> <tr> <th width=95 height=30 align="right">部署:</th> <td width=100> <select name="busyo"></select> </td> <th width=80 align="right">営業所:</th> <td width=100> <select name="eigyousyo"></select> </td> <th width= 80 align="right">担当コード:</th> <td width=450> <select name="tantocode"></select> </td>   </tr> </table> <table border=1cellspacing=0cellpadding=2width=760> <tr> <th width=80 align="right">権限:</th> <td width=700> <select name="kengen"></select> </td> </tr> </table> </form> </html>

  • ブラウザによってテーブルのセルの高さが変わる

    質問させて頂きます。 現在、テーブルを使用して表を作っているのですが、 ブラウザによってセルの高さが変わってしまいます。 safariでは思った通りのレイアウトになるのですが、 chrome、Firefoxでは [ height ] の値が反映されていないのか、 崩れてしまいます。 添付は希望するレイアウト(safariではこのように表示されます)です。 ソースを記載しますので、どなたかご教示お願い致します。 --- html --- <table class="hogs" cellspacing="5"> <tr> <td width="180" height="184" rowspan="3"><img src="img/001.gif" width="180" height="184" alt=""/></td> <th height="22">項目1</th> <td>文章1</td> </tr> <tr> <th height="22">項目2</th><td height="22">文章2</td> </tr> <tr> <th height="140" valign="top">項目3</th><td valign="top">文章3</td> </tr> </table> --- CSS --- table.hoge { background-color: rgba(50,50,50,0.3); width: 640px; height: 184px; margin: 0 auto 18px; padding: 10px; } table.hoge th { height: 22px; background-color: #7ac0c9; width: 80px; } table.hoge td { padding: 0 20px; }

    • ベストアンサー
    • HTML
  • borderが1のテーブル

    ボーダーが1ピクセルくらいの表を作りたいので、tableの入れ子で作ったのですが「tableの入れ子は良くない」ととあるサイトで読んだので、入れ子にしないでtableを作りたいのですが何か良い方法はありますでしょうか? 私が書いたのはこんなかんじです。 <table width="400" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#000000"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1"> <tr bgcolor="#999999"> <th><div align="center"><font size="2">名称</font></div></th> <th><div align="center"><font size="2">模型材質</font></div></th> <th><div align="center"><font size="2">生産材質</font></div></th> </tr> <tr bgcolor="#FFFFFF"> <td bgcolor="#999999"><div align="center"><font size="2">本体</font></div></td> <td><div align="center"><font size="2">発泡塩ビ板</font></div></td> <td><div align="center"><font size="2">プラスチック</font></div></td> </tr> </table></td> </tr> </table> CSSで「style="border-width :1px 1px 1px 1px;border-style : solid solid solid solid ;border-color :#000000 #000000 #000000 #000000 ;"」というのを入れてやってみたのですが、これだと外側にしかラインが表示されませんでした。 よろしくおねがいします。

  • テーブルの中にテーブルを入れ込んで・・・

    最近、質問ばかりしてるような気がするのですが・・・ m(__)m 親テーブルのセルの中に子テーブルを入れ込んで 子テーブルを親テーブルのセルの縦位置を中央に表示させたいのですがうまく行きません NN6.Xでは表示されるのですがIEだと上寄せに 表示されてしまいます。 これはIEの仕様でしょうがないのでしょうか? (↑けしてダジャレではありません(^^ゞ) セル内配置でテキストや画像は上手く 中央位置に出来るのですが子テーブルが出来ないです なぜでしょうか? 参考のためにソースコードを --------------------------------- <table width="100%" border="1" height="100%"> <tr> <td align="center" valign="middle"> <table width="50%" border="1" height="50%"> <tr> <td> </td> </tr> </table> </td> </tr> </table> ------------------------------------- よろしくお願いします。 スタイルシートやjavascriptを使ったやりかた とかもあるのでしょうか?

    • ベストアンサー
    • HTML
  • IEでテーブル内のテキストが勝手に改行されます。

    個人でサイトを運営しているのですが、 外部CSSをテーブルに適用するとIEとFirefoxで表示が変わってしまい 困っています。問題は下記です。 テーブルに指定するCSSは以下のようなものです。 table.1{ border-top:1px solid #666666 ; border-left:1px solid #666666 ; border-collapse:collapse; border-spacing:0; background-color:#ffffff; empty-cells:show; text-align:left; font-size: 10pt; padding:3px; } .1 th{ border-right:1px solid #666666 ; border-bottom:1px solid #666666 ; color:#330000; background-color:#996633; padding:0.1em 0.1em; text-align:center; } .1 td{ border-right:1px solid #666666 ; border-bottom:1px solid #666666 ; padding:8px 8px 8px 8px; line-height: 120%; } そして本文のHTMLです。 <table width="166" border="0" class="1"> <tr> <td colspan="2"><div align="center">テキストテキスト</div></td> </tr> <tr> <td>イメージ写真</td> <td>イメージ写真</td> </tr> <tr> <td width="76"><p>テキストテキストテキストテキストテキストテキストテキストテキスト</p></td> <td width="79"><p>テキストテキストテキストテキストテキストテキストテキストテキスト</p></td> </tr> </table> 以上のようなものです。 このようにするとFirefoxではきちんと表示されるのですが、 IEだとテキストの部分が4文字ほどで勝手に改行されてしまい、 かなり縦長のテーブルになってしまいます。 試行錯誤してみたのですが、全然できなくて本当に困っています。 もし解決策をご存知の方おられましたら、ぜひ教えていただければ幸いです。

    • ベストアンサー
    • HTML

専門家に質問してみよう