テーブルで表示させている内容をJavaScriptを使って行ごとに表示/非表示の切り替えができるようにしたのですが、表示させた時、IEでは通常のテーブル表示のように表示されるのですが、FirefoxやSafariでは何故かテーブルの一番左の<tr>要素内に全ての<td>要素が入る形で表示されてしまいます。多分CSSの書き方に関係していると思われるのですが、どなたか分かる方アドバイスをお願い致します。
下記は、コードの抜粋です。
[CSS]
(略)
#content {
padding: 10px 0;
width: 780px;
float: left;
}
#inquiry {
width: 600px; /* ボックスの幅を指定 */
margin-left: auto;
margin-right: auto;
}
#inquiry table {
border-top: 1px solid #CCCCCC;
border-bottom: none;
border-left: none;
border-right: 1px solid #CCCCCC;
font-size: 100%;
width: 100%;
}
#inquiry td {
border-top: none;
border-bottom: 1px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
border-right: none;
padding: 10px;
text-align: center;
}
#inquiry th {
border-top: none;
border-bottom: 1px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
border-right: none;
background-color: #F3F3F3;
font-weight: normal;
padding: 10px;
}
(略)
[HTML]
(略)
<script type="text/javascript" src="../../webroot/js/prototype.js"></script>
<script type="text/javascript">
<!--
function OnScreenHelp(id){
var elem = document.getElementsByClassName(id);
for(var i=0;i<elem.length;i++) {
elem[i].style.display = elem[i].style.display == "none" ? "block" : "none";
}
}
//-->
</script>
(略)
<table border="border" summary="購入履歴" cellspacing="0">
<caption><h3>購入履歴</h3></caption>
<tr>
<th scope="col"><label for="name">注文番号</label></th>
<th scope="col"><label for="name">ご注文日</label></th>
<th scope="col"><label for="name">合計金額</label></th>
<th scope="col"><label for="name">備考</label></th>
</tr>
<?php
foreach($data1 as $row1) {
$id = $row1['Order']['id']; ?>
<tr onclick="OnScreenHelp(<?php echo $id; ?>)">
<td><?php echo h($row1['Order']['id']); ?></td>
<td><?php echo h($row1['Order']['orderdate']); ?></td>
<td><?php echo h($row1['Order']['total']); ?></td>
<td><input type="text" name="name" size="30" id="name" class="text1" value="送料込み" /></td>
</tr>
<?php } ?>
</table><br />
<table border="border" summary="明細情報" cellspacing="0">
<caption><h3>明細</h3></caption>
<tr>
<th scope="col"><label for="customerno">商品番号</label></th>
<th scope="col"><label for="name">商品名</label></th>
<th scope="col"><label for="price">価格</label></th>
<th scope="col"><label for="quantity">数量</label></th>
<th scope="col"><label for="subtotal">小計</label></th>
</tr>
<?php foreach($data2 as $row2) {
$id = $row2['Orderitem']['order_id']; ?>
<tr class="<?php echo $id; ?>" style="display:none;">
<td><?php echo h($row2['Product']['productno']); ?></td>
<td><?php echo h($row2['Product']['name']); ?></td>
<td><?php echo h($row2['Product']['price']); ?></td>
<td><?php echo h($row2['Orderitem']['quantity']); ?></td>
<td><?php echo h($row2['Orderitem']['subtotal']); ?></td>
</tr>
<?php } ?>
</table>
(略)
No.1ベストアンサー
- 回答日時:
displayの値がblockだと、単純なボックスになるけど
display:table-row;
で、HTMLで言うところのtrになる。この場合table-cellかも。
displayで指定するのは、見せる見せないではなく、それをどのような要素にするかということ。
9.2.5 'display'プロパティ(The 'display' property) ( http://www.swlab.it.okayama-u.ac.jp/man/rec-css2 … )
いちいちIDで指定していたら、同じ指定をたくさん書かなくてはならない。(CSSのCSSたる)カスケーディングをうまく使う。=継承されるプロパティ、詳細度、要素セレクタ、子孫セレクタ、隣接セレクタ、クラスセレクタ、擬似クラスセレクタ、擬似要素・・・
下は、thにホーバーすると、tdを見せる方法。table全体とか、様々に使える。visibilityをつかっても良いかな・・
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">
<title>サンプル</title>
<meta name="author" content="ORUKA1951">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rev="made" href="mailto:oruka1951@hoge.com" title="send a mail" >
<link rel="START" href="../index.html">
<style type="text/css">
<!--
table[summary=focus]{border-collapse:collapse;}
table[summary=focus],table[summary=focus] th,table[summary=focus] td{border:solid 1px gray;}
table[summary=focus] tr.test td{display:none;}
table[summary=focus] tr.test th:hover+td,
table[summary=focus] tr.test th:hover+td+td{display:table-cell;}
-->
</style>
</head>
<body>
<h1>サンプル</h1>
<table summary="focus" >
<tbody>
<tr>
<th abbr="見出し">見出し</th><th abbr="見出し2">見出し</th><th abbr="見出し3">見出し</th>
</tr>
<tr>
<th abbr="a">値</th><td>123</td><td>456</td>
</tr>
<tr class="test">
<th abbr="a">値</th><td>123</td><td>456</td>
</tr>
<tr>
<th abbr="a">値</th><td>123</td><td>456</td>
</tr>
</tbody>
</table>
</body>
</html>
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- HTML・CSS CSS のみのタブ切り替えについて 1 2023/01/11 16:47
- HTML・CSS CSSが効かずどのように指定すれば良いか分からないのでアドバイスお願い致します 2 2023/06/07 12:25
- PHP htmlで複数の個数入力欄を表示させるには 1 2022/09/20 03:11
- JavaScript ①入力フォーム→②確認表示画面→③送信完了画面のコードを書いているのです、 入力フォームから受け取っ 2 2022/05/10 16:45
- Visual Basic(VBA) Selenium.ChromeDriverの使い方について 7 2022/09/22 06:43
- AJAX JavascriptからPHPへのAjax通信でnullが返ってくる 3 2022/08/03 22:00
- JavaScript clear機能を失わずにファイルアップロード機能を作成したい 3 2023/06/10 16:12
- JavaScript Javascriptが機能せず原因が分からないので教えて頂きたいです 3 2023/06/04 14:50
- PHP アップロード画像数でCSSを分けることに成功したのですが、画像の横に文字を並べることが出来ません。 3 2023/07/28 17:16
- HTML・CSS テーブルタグのセルの幅の一部だけを指定 1 2023/03/12 12:02
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
html でのテキスト結合について
-
td width="180" と固定してるの...
-
tableタグとformタグの組み合わせ
-
ブラウザの文字サイズを変える...
-
Firefoxを使ってるのですがズー...
-
ブラウザ上でのタブ・シフトタ...
-
太字にするやり方
-
テーブルのセル内の隙間を取れ...
-
同じクラス名はつけないほうが...
-
4カラムのテーブルに絶対幅と相...
-
IEだけの現象 form内の部品が...
-
tableにul,または,olを入れられ...
-
テーブルとテーブルの間隔について
-
HTMLエラーを自動修正するソフ...
-
TABLEのセルの中の文字を行単位...
-
テーブルの行を折りたたみたい...
-
線が一番細いテーブル
-
テーブルの装飾
-
テーブルのセルに画像をピッタ...
-
テーブルの位置を細かく指定し...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
html でのテキスト結合について
-
tableタグとformタグの組み合わせ
-
テーブルの一部分のセルだけに...
-
同じクラス名はつけないほうが...
-
テーブル内のテーブルの高さを...
-
XHTMLに関する質問 順序が逆に...
-
Tableタグ内のspan styleが適応...
-
Tableタグで作成した表の縮小
-
ブラウザによってテーブルのセ...
-
cssで、テーブルのtdの中の文字...
-
td要素内のdiv要素をセンタリン...
-
vbscriptで時計を作りたい
-
formのinputなどの幅100%指定
-
Firefoxを使ってるのですがズー...
-
テーブルの枠線に色が付かない
-
divで囲んだ文字が消える
-
TDタグ内での均等割付の仕方
-
表とリスト(ulとtable)の違い...
-
firefoxで「height: 100%;」と...
-
<img>タグにCSSのclass設定可能?
おすすめ情報