いくつかのdivコンテナを持つhtmlページがあります。その1つにテーブルがあります。 外部のスタイルシートを使用していますが、何を試しても、最初の列のサイズを変更することはできません。
"table-layout:fixed;"を設定しました。カラムに "width"と "max-width"を使用しようとしましたが、私が何もしないとカラムのサイズを変更できます。
誰かがこの列のサイズを変更できない理由を指摘できますか?
このサイズ変更を中止する他の属性が機能していませんか? divコンテナの1つはここで問題を引き起こしますか?固定レイアウトテーブルの列サイズを変更できません
https://jsfiddle.net/Shiroslullaby/ahstbwd5/2/
私はいくつかの余分なCSSを持っていますが、それは私がそのここに問題を引き起こしていることを小さなチャンスで無傷ですべてのものを残しているホバーにhighlitingのようなものを、行います。
HTML:
<html>
<head>
<title>Customers</title>
<link rel="stylesheet" href="test2.css">
</head>
<body>
<div id="header"></div>
<div id="container">
<div class="left">
<table class="customertable">
<thead>
<tr>
<th class="shortcolumn">id</th><th>businessName</th><th>contactName</th>
<th>contactEmail</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td><td>Microsoft</td><td>Bill Gates</td><td>[email protected]</td>
</tr>
<tr>
<td>2</td><td>Amazon</td><td>Jeff Bezos</td><td>[email protected]</td>
</tr>
</tbody>
</table>
</div>
<div class="right"><div id="fixedright"></div></div>
</div>
<div id="footer"></div>
</body>
</html>
CSS:あなたはここで
.customertable {
table-layout: fixed;
overflow-x:auto;
width: 100%;
word-wrap: break-word;
}
.shortcolumn {
max-width: 10%;
}
#container {
position: relative;
width: 100%
}
div {
border-radius: 5px;
}
#header {
height: 50px;
background-color: #F38630;
margin-bottom: 10px;
}
.left {
width: 75%;
background-color: #A7DBD8;
margin-bottom: 10px;
}
.right {
height: 100%;
width: 25%;
background-color: #E0E4CC;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
margin-bottom: 10px;
}
#footer {
height: 50px;
background-color: #69D2E7;
clear: both;
}
#fixedright {
height: 50px;
width: calc(25% - 6px);
background-color: #FFFFFF;
position: fixed;
margin: 1px 1px 1px 1px;
}
thead {
background: #231E5E;
color: #FFF;
}
tbody tr:nth-child(odd) {
background: #E9F5D7;
}
tbody tr:hover {
background-color: #86C133;
}
はい、それが働いています! 私はいくつかの変更を加える前に "幅"を使用しようとしましたが、動作しませんでした。おそらく私はテーブルレイアウトを設定していませんでした:固定プロパティー... – Shiroslullaby
おそらく、あなたはテーブルレイアウトの正しい組み合わせを試しませんでした。お役に立てて嬉しいです! – scooterlord