• ベストアンサー

テーブルの中の下には少し空白を入れたい場合

table[summary="回答"] td{ padding:0px 5px; } これで上下左右に空白を入れられますが、 テーブルの中の上には空白を入れたくなくて、 テーブルの中の下には少し空白を入れたい場合どうすればいいですか? table[summary="回答"] td{ padding:0px 5px; } これだと上下どちらも空白がなくなるので、 table[summary="回答"] td{ padding:0px 5px; margin-bottom:20px; } にしたのですが、 margin-bottom:20px; は適用されてません。

  • CSS
  • 回答数1
  • ありがとう数1

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

  • ベストアンサー
  • byDesign
  • ベストアンサー率75% (45/60)
回答No.1

>padding:0px 5px; paddingは1~4つの値が設定でき、値を設定した数により適用位置が決まります。 padding : 1px;        上下左右:1px padding : 1px 2px;      上下:1px 左右:2px padding : 1px 2px 3px;    上:1px 左右:2px 下:3px padding : 1px 2px 3px 4px;  上:1px 右:2px 下3:px 左:4px また、paddingは上下左右を一括定義する方法ですが、個別に指定する事も出来ます padding-top : 5px; padding-bottom : 5px; padding-left : 5px; padding-right : 5px; これを踏まえて、上のpaddingだけ0にする場合の一例です 例1) padding : 0 5px 5px; 例2) topだけ上書きする padding : 5px; padding-top : 0;

ttisldyv
質問者

お礼

ありがとうございました。

関連するQ&A

  • paddingはテーブルに対して行えないの?

    cssのpaddingはテーブルに対して行えないのでしょうか? table[summary="table_あ"] { text-align: center; padding: 20px 0px; } というcssを設定すると text-align: center; は適用されているのに padding: 20px 0px; は無視されます。 http://www.tagindex.com/stylesheet/table/padding.html を参考にしたのですが、 もしかして、 tableでpaddingは使えないのでしょうか? 上下のみ空白が欲しいので20px 0pxとしました。

    • ベストアンサー
    • HTML
  • テーブルの下に余白を100px作りたいです。

    cssで table[summary="test"] { font-size: 0.8em; padding: 0px 0px 100px; } としてるのに、 padding: 0px 0px 100px; だけ適用されないのですが、何故でしょうか? テーブルの下に余白を100px作りたいです。

    • ベストアンサー
    • CSS
  • table[summary="table_1"]

    table[summary="table_1"] td,th{ padding: 5px 10px; } とスタイルシートで設定した場合、 <table summary="table_2"> のthには、 padding: 5px 10px;は適用されないですよね? 上記のcssでthタグにpadding: 5px 10px;が出来ようされるのは、 "table_1"だけですよね?

    • ベストアンサー
    • CSS
  • table padding:

    table[summary="table名"] { padding: 5px 10px; } が適用されないのですが、これは仕様ですか?

    • ベストアンサー
    • CSS
  • テーブルの中にiframe

    テーブルの中にiframeをしているのですが どうしてもボタンが右側に少しはみ出ますし iframeは縦400pxを超えるページを表示すると 縦スクロールバーが表示されますが それも右側にはみ出ます。 どうにか800pxの中に収まらないものでしょうか? また、ボタンのボーダを下記ソースでは消していますが デフォルトで表示される立体感のあるボタンのまま 800pxの中に収めたいです。 HTML5、CSS2.1です。 ご相談お願いします。 <table> <tr style="width: 800px; height: 50px"> <td><input type="button" value="1"/></td> <td><input type="button" value="2"/></td> <td><input type="button" value="3"/></td> <td><input type="button" value="4"/></td> <td><input type="button" value="5"/></td> </tr> <tr style="width: 800px; height: 400px"> <td colspan="5" style="width: 800px; height: 400px"> <iframe src="hoge.htm"></iframe> </td> </tr> <tr style="width: 800px; height: 50px"> <td colspan="5" style="width: 800px; height: 50px"> <p>hoge</p> </td> </tr> </table> ------------------------------------------------------------ table { padding: 0px; margin: 0px; border-style: none; border-width: 0px; } tr td { padding: 0px; margin: 0px; border-style: none; border-width: 0px; } input { border-style: none; border-width: 0px; padding: 0px; margin: 0px; color: Red; width: 160px; height: 50px; font-size: 20px; font-family: HGS明朝B; background-color: transparent; } iframe { padding: 0px; margin: 0px; border-style: none; border-width: 0px; background-color: transparent; width: 800px; height: 400px; }

    • ベストアンサー
    • HTML
  • tr 無視されます padding

    テーブルに対してcssで table[summary="トップページ"] tr{ padding:30px 30px; } は効かないのですか? table[summary="トップページ"] th{ padding:30px 30px; } や table[summary="トップページ"] td{ padding:30px 30px; } は適用されますが tr だけが無視されます。

    • ベストアンサー
    • HTML
  • テーブルのセル間に余白が空いてしまいます

    2行×2列と3行×2列のテーブルを1つずつ作成し、どちらのテーブルも1列目のセルは結合して画像を挿入し、2列目のセルに文字を入力するというスタイルを取りたいです。 しかし、画像と文字の間(1列目と2列目の間)に余分な空白ができてしまいます。 margin、padding、cellspaceなどが必要ではないかと推測していますが、どこに埋め込むのか、自分なりに試しましたがわかりません。 htmlのコードとcssのコードを記しますので、どなたかお詳しい方お力を貸していただけませんでしょうか? また、もう1点困っていることが、テーブルとテーブルの間にスペース開けたいのですが、<br>はできるだけ使いたくありません。 divにmarginを指定して、テーブルタグの上に<div style="margin-top:10px"></div>とすればスペースは空きましたが、他に方法があれば合わせて教えていただけると嬉しいです。 <!-- htmlのコード --> <body> <table width="700" border="0" > <tr> <td><center> <img src="img/top_image.png" /> </center></td> </tr> <table class="table001"> <tr> <td rowspan="2"><img src="img/aaa.bmp" /></td> <td><h2>このサイトのごあんない</h2></td> </tr> <tr> <td><p>このサイトは~~~~~~</p></td> </tr> </table> <div style="margin-top:10px"></div> <table class="table001"> <tr> <td rowspan="3"><img src="img/bbb.bmp" /></td> <td><h2>このサイトのごあんない2</h2></td> </tr> <tr> <td> <p>このサイトは~~~~~~</p> <p>また、このサイトの~~~~~~。</p> </td> </tr> <tr> <td> <p>問い合わせ</p> <p>電話番号 000-000-0000</p> </td> </tr> </table> </body> /* CSSのコード */ body { background-color:#6C6; margin-top: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; padding-bottom: 0px; font-size: 0.8em; font-family: "メイリオ", "Meiryo", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "MS Pゴシック", "MS P Gothic",sans-serif ; } #pageBody { width: 760px ; margin-top: 20px; margin-right: auto; margin-left: auto; background-color: #FFF; } table.table001{ background-color: #E8FECF; width: 700px; margin-left: auto; margin-right: auto; white-space:normal; } h2{ padding-left: 10px; background-color: #009900; width: 180px; color:#FFF; font-size: 1.1em; height: 25px; line-height:25px; }

    • ベストアンサー
    • HTML
  • cssを一つにまとめる事はできますか?

    table[summary="テーブル"] th{ padding:0px 0px; } table[summary="テーブル"] td{ padding:0px 10px; } という、cssを一つにまとめる事はできますか? table[summary="テーブル"] th,td{ padding:0px 0px; } とすると、うまく表示されません。

    • ベストアンサー
    • CSS
  • borderをページの下まで伸ばしたい

    お世話になります。既出の質問を見たのですが、解決できず質問させていただきます。 テーブルを使い左右にレイアウトを分けています。 左のメニュー部分の上下両サイドにborderを設定していますが、メニュー部分の方が圧倒的にメインよりコンテンツが少なく、ページの途中でborderが途切れてしまいます。 メインコンテンツの縦量に合わせて下まで伸びて欲しいのですが、どうすればいいのでしょうか? 恐れ入りますが下記ソースです。 /*CSS*/ body { margin: 0px auto; padding: 0px; height:100%; width: 760px; text-align:center; position:relative; } #header { padding:0px ; margin: 0px auto; width: 760px; height: auto; } #contents { margin: 0px auto; padding: 0px; height:100%; width: 760px; background-color:#FFFFFF } .side{/*メニュー部分*/ margin:0px; padding:0px 0px 20px; border:1px #666666 solid ; width:163px; height:auto; } .footer {/*フッターの背景画像サイズに合わせheightを設定*/ margin:0px; padding:10px; width: 760px; height:72px; text-align:left; background-image:url(image/bottom.gif); background-repeat:no-repeat; border:0px; } .coretable{/*画面レイアウト左右分けテーブル*/ margin:5px 0px 0px; padding:0px; width:760px; } <!--html--> <body> <div id="header"> ヘッダー内容 </div> <div id="contents"> <table border="0" cellpadding="0" cellspacing="0" class="coretable"> <tr><td width="165" align="center" valign="top"> <div class="side"> メニュー内容 </div> </td> <td width="595" align="center" valign="top"> メインコンテンツ内容 </td> </tr> </table> </div> <div id="footer"> フッター内容 </div> </body> </html> あるサイトで拝見して、 .sideに height:100%;/* for IE6 */ min-height:100%; を加え、 html{ height:100%; } body{ height:100%;} としてみたところ、borderは伸びず、footerがページの途中に上がってきてしまうという現象でした。 テーブルを使っているのが悪いのでしょうか? どうかお知恵をお貸し下さい。

    • ベストアンサー
    • CSS
  • table cellpadding「有」又は「無し」でCSSの解釈違う?

    IE6,7 tableのcellpaddingをcellpadding="0"と表記してスタイルシートでセルのpaddingを指定するのと、cellpadding="0"と表記せずにスタイルシートでセルのpaddingを指定するのとでは、ブラウザーのテールブルの解釈(表示)が違うのですが、スタイルシートでセルのpaddingを指定する場合、HTMLのcellpaddingをcellpadding="0"と表記するべきですか又は表記しないべきですか? 以下の二つのコードの違いは、<table>タグにcellpadding="0"が「ある」か「ない」かだけですが、例2のコードのテーブルの方が例1のテーブルより全体的な幅が広く表示されます。 <例1:cellpadding="0"あり> <html> <head> <style type="text/css"> .ta { margin-top:20px; margin-bottom:20px; table-layout:fixed; } .ta_ti { padding-top:5px; padding-bottom:5px; text-align:center; font-size:18px; font-weight:900; line-height:180%; } .ta_he { font-size:16px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; line-height:180%; font-weight:900; } .ta_da { padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; line-height:180%; } </style> </head> <body> <table class="ta" width="550" border="0" cellspacing="1" cellpadding="0"> <colgroup> <col width="200"> <col width="347"> </colgroup> <tr> <td class="ta_ti" colspan="2"> タイトル </td> </tr> <tr> <td class="ta_he"> 見出し </td> <td class="ta_da"> データ </td> </tr> </table> </body> </html> <例2:cellpadding="0"無し> <html> <head> <style type="text/css"> .ta { margin-top:20px; margin-bottom:20px; table-layout:fixed; } .ta_ti { padding-top:5px; padding-bottom:5px; text-align:center; font-size:18px; font-weight:900; line-height:180%; } .ta_he { font-size:16px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; line-height:180%; font-weight:900; } .ta_da { padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; line-height:180%; } </style> </head> <body> <table class="ta" width="550" border="0" cellspacing="1"> <colgroup> <col width="200"> <col width="347"> </colgroup> <tr> <td class="ta_ti" colspan="2"> タイトル </td> </tr> <tr> <td class="ta_he"> 見出し </td> <td class="ta_da"> データ </td> </tr> </table> </body> </html>

    • ベストアンサー
    • HTML