3

我有一张桌子有几个不同的<input type = 'text'>. 有些应该是 64 个字符,有些是 7 个字符,有些是 4 个字符。幸运的是,它们都组合在一起,所以我认为最好的方法是为每个部分设置多个 div 标签。但是,当我尝试调整 CSS 中的宽度时,没有任何输入发生变化。是什么赋予了?我有一个外部 CSS。表格代码和CSS代码如下

附带说明一下,我知道 64px != 64 个字符

编辑:修复了工作 html 代码。

桌子:

<?php
    require_once('auth.php');
    //Include database connection details
    require_once('config.php');
  ?>

    <html>
      <head>
        <title>Edit Profile</title>
        <link rel = 'stylesheet' type = 'text/css' href = 'default.css' />
      </head>
    <body>
      <div id = 'sideContainer'>
        <div id = 'navMain'>
          <?php include 'sidebar.html'; ?>
        </div>
      </div>
      <div id = 'content'>
        <?php
          $memberID = $_SESSION['SESS_MEMBER_ID'];
          $query = "SELECT * FROM memberData WHERE member_ID = '$memberID'";
          $result = mysql_query($query);
          while($row = mysql_fetch_assoc($result)){
            $vCode = $row['vCode'];
            $keyID = $row['keyID'];
            $mlYeild = $row['mlYeild'];
            $cycleTime = $row['cycleTime'];
            $veld = $row['veld'];
            $scor = $row['scor'];
            $pyro = $row['pyro'];
            $plag = $row['plag'];
            $omber = $row['omber'];
            $kern = $row['kern'];
            $jas = $row['jas'];
            $hemo = $row['hemo'];
            $gneiss = $row['gneiss'];
            $ochre = $row['ochre'];
            $spod = $row['spod'];
            $crok = $row['crok'];
            $bistot = $row['bistot'];
            $ark = $row['ark'];
            $merc = $row['merc'];

          }
        ?>
        <form id = 'editPlayerInfo' name = 'editPlayerInfo' method = 'post' action = 'editUser-exec.php'>
          <table border = '0'>
            <tr>
              <td colspan = '2'><h2>API stuff</h2></td>
            </tr>
            <tr>
              <td><h3>vCode</h3></td>
              <td><div id = 'vCode'><input type = 'text' name = 'vCode' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
            </tr>
            <tr>
              <td><h3>keyID</h3></td>
              <td><div id = 'keyID'><input name = 'keyID' type = 'text' value = '<?php echo $keyID; ?>'></div>
              </td>
            </tr>
          </table>
          <HR>
          <div id = 'refining'>
            <table>
              <tr>
                <td colspan  = '4'><h2>Mining Laser stuff</h2></td>
              </tr>
              <tr> 
                <td><h3>Mining Laser Yeild</h3></td>
                <td><input name = 'mlYeild' type = 'text' class = 'textfield' id = 'mlYeild' value = '<?php echo $mlYeild; ?>'/></td>
              </tr>
              <tr>
                <td><h3>Cycle Time</h3></td>
                <td><input name = 'cycleTime' type = 'text' class = 'textfield' id = 'cycleTime' value = '<?php echo $cycleTime; ?>'/></td>
              </tr>
            </table>
            <HR>
            <table>
              <tr>
                <td colspan  = '6'><h2>Yeild Specifics</h2></td>
              </tr>
                <td><h3>Veldspar Yeild</h3></td>
                <td><input name = 'veldYeild' type = 'text' class = 'textfield' id = 'veldYeild' value = '<?php echo $veld; ?>'/></td>
                <td><h3>Scordite Yeild</h3></td>
                <td><input name = 'scorYeild' type = 'text' class = 'textfield' id = 'scorYeild' value = '<?php echo $scor; ?>'/></td>
                <td><h3>Pyroxeres Yeild</h3></td>
                <td><input name = 'pyroYeild' type = 'text' class = 'textfield' id = 'pyroYeild' value = '<?php echo $pyro; ?>'/></td>            
              </tr>
              <tr>
                <td><h3>Plagioclase Yeild</h3></td>
                <td><input name = 'plagYeild' type = 'text' class = 'textfield' id = 'plagYeild' value = '<?php echo $plag; ?>'/></td>
                <td><h3>Omber Yeild</h3></td>
                <td><input name = 'omberYeild' type = 'text' class = 'textfield' id = 'omberYeild' value = '<?php echo $omber; ?>'/></td>
                <td><h3>Kernite Yeild</h3></td>
                <td><input name = 'kernYeild' type = 'text' class = 'textfield' id = 'kernYeild' value = '<?php echo $kern; ?>'/></td>
              </tr>
              <tr>
                <td><h3>Jaspet Yeild</h3></td>
                <td><input name = 'jasYeild' type = 'text' class = 'textfield' id = 'jasYeild' value = '<?php echo $jas; ?>'/></td>
                <td><h3>Hemorphite Yeild</h3></td>
                <td><input name = 'hemYeild' type = 'text' class = 'textfield' id = 'hemYeild' value = '<?php echo $hemo; ?>'/></td>
                <td><h3>Gneiss Yeild</h3></td>
                <td><input name = 'gneissYeild' type = 'text' class = 'textfield' id = 'gneissYeild' value = '<?php echo $gneiss; ?>'/></td>          
              </tr>
              <tr>
                <td><h3>Dark ochre Yeild</h3></td>
                <td><input name = 'ochreYeild' type = 'text' class = 'textfield' id = 'ochreYeild' value = '<?php echo $ochre; ?>'/></td>
                <td><h3>Spodumain Yeild</h3></td>
                <td><input name = 'spodYield' type = 'text' class = 'textfield' id = 'spodYield' value = '<?php echo $spod; ?>'/></td>
                <td><h3>Crokite Yeild</h3></td>
                <td><input name = 'crokYeild' type = 'text' class = 'textfield' id = 'crokYeild' value = '<?php echo $crok; ?>'/></td>
              </tr>
              <tr>
                <td><h3>Bistot Yeild</h3></td>
                <td><input name = 'bisYeild' type = 'text' class = 'textfield' id = 'bisYeild' value = '<?php echo $bistot; ?>'/></td>
                <td><h3>Arkonor Yeild</h3></td>
                <td><input name = 'arkYeild' type = 'text' class = 'textfield' id = 'arkYeild' value = '<?php echo $ark; ?>'/></td>
                <td><h3>Mercoxit Yeild</h3></td>
                <td><input name = 'mercYeild' type = 'text' class = 'textfield' id = 'mercYeild' value = '<?php echo $merc; ?>'/></td>
              </tr>
            </table>
            <table align = 'center'>
              <tr>
                <td><input type = 'submit' value = 'Make Changes'></td>
              </tr>
            </table>
          </form>
        </div>
      </div>
    </body>
  </html>

CSS

  #sideContainer {float:left;}
#content {
  float:left;
  padding-left: 5px;
}
#content table {
  border-spacing:10;
  border-collapse:collapse;
}
#content h1 {
  vertical-align:top;
  height:40px; overflow:;
  color: #99CC00;
  margin: 0px 0px 5px;
  padding: 0px 0px 3px;
  font: bold 18px Verdana, Arial, Helvetica, sans-serif;
  border-bottom: 1px dashed #E6E8ED;
}
#content h2 {
  vertical-align:top;
  height:40px; overflow:;
  color: #336622;
  margin: 0px 0px 5px;
  padding: 0px 0px 3px;
  font: bold 24px Verdana, Arial, Helvetica, sans-serif;
  border-bottom: 1px dashed #E6E8ED;
}
#content h3 {
  text-align:bottom;
  height:30px; overflow:;
  color: #99CC00;
  margin: 0px 0px 5px;
  padding: 0px 0px 3px;
  font: bold 18px Verdana, Arial, Helvetica, sans-serif;
  border-bottom: 1px dashed #E6E8ED;
}
#content th {
  font-weight: bold;
  text-align: left;
}
#content a {
  color: #2D3954;
  font-size: 11px;
}
#content a:hover {
  color: #99CC00;
}
#userTable input{
  vertical-align:center;
  margin: 0px 0px 5px;
  padding: 0px 0px 3px;
  background: #ccffaa;
}
#vCode input{
  width: 10px;
}
#keyID input{
  width:100px;
}
#refining input{
  width:50px;
}


#sideTable {
  float:left;
  padding-left: 5px;
}



.err {
  color: #FF9900;
}

#navMain {
  margin-left:25px;
  color:#c3c3c3;
  font-family:Tahoma, Geneva, sans-serif;
}
#navMain h2{
  font-family:Trebuchet MS1, Helvetica, sans-serif;
} /*Change font of the title*/


#navMain ul{
  padding:0;
  margin:0;
  margin-left:25px;
  font-size:15;
  margin-right:20px;
} /*Reset the default padding/margin and set it as required*/


#navMain ul li a{
  font-size:15;
  text-decoration:none;
  color:#c3c3c3;
} /*Change color of link text and remove underline*/


#navMain ul li a:hover{
  color:#e0993e;
} /*Change color of hover text*

边栏.html

<h2>Categories</h2>
<ul>
<li><a href="editUser-form.php">Edit Personal Info</a></li>
<li><a href="sellToCorp-form.php">Sell to Corp</a></li>
<li><a href="fleet-form.php">Fleet Log Parser</a></li>
<li><a href="theoreticalMining.php">Theoretical Mining</a></li>
<li><a href="theoreticalRefining.php">Theoretical Refining</a></li>
<li><a href="corpMail-form.php">Send Corp Mail - N/A</a></li>
<li><a href="setCorpRate-form.php">Set Corp Rate</a></li>
<li><a href="updateSkillList.php">Update Skills</a></li>
<li><a href="logout.php">logout</a></li>
</ul>
4

3 回答 3

2

您需要将 div 移动到 td 标签内。像这样的东西:

<div id='content'>some content is here
  <div id='userTable'>
    <table>
  <tr>
    <th>table header</th>
  </tr>
  <tr>
    <td>
      <div id='chars64'>
        <input type='text' value='1234567812345678123456781234567812345678123456781234567812345678'>
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div id='chars7'>
        <input type='text' value='1234567'>
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div id='chars4'>
        <input type='text' value='0.123'>
      </div>
    </td>
  </tr>
</table>

这是它的 jsfiddle:http: //jsfiddle.net/TM5Mk/

你也可以参考这些之前的讨论:

div inside table 在表格单元格中放置一个 div

于 2013-01-13T11:08:38.773 回答
1

您没有有效的 HTML 表格。

您应该在div元素内包含td元素,然后设置输入样式。在元素<div>之前添加无效。tr

工作小提琴| | 更新的工作小提琴

<div id = 'content'>
    some content is here
    <div id = 'userTable'>
        <table>
            <tr>
                <th>table header</th>
            </tr>
                <tr>
                    <td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
                    <td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
                    <td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
                    <td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
                </tr>
                <tr>
                    <td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
                    <td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
                    <td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
                </tr>
                <tr>
                    <td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
                    <td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
                    <td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
                </tr>
        </table>
    </div>
</div>
于 2013-01-13T11:01:27.167 回答
1

我认为那是因为您的 HTML 是错误的。您可以将<table>元素放入<div>. 只需将输入包装在<div>.. 而不是整个<tr>. 这是:

<div id = "content">
    some content is here
    <div id = "userTable">
        <table>
            <tr>
                <th>table header</th>
            </tr>
                <tr>
                    <td> 
                        <div id = "chars64">
                            <input type = "text" value = "1234567812345678123456781234567812345678123456781234567812345678">
                        </div>
                    </td>  
                </tr>
                <tr>
                    <td> 
                        <div id = "chars7">
                            <input type = "text" value = "1234567">
                        </div>
                    </td>
                </tr>
                <tr>    
                    <td>
                        <div id = "chars4">
                            <input type = "text" value = "0.123"> 
                        </div>
                    </td>
                </tr>
        </table>
    </div>
</div>
于 2013-01-13T11:02:06.377 回答