1

関連する質問がたくさん見つかりましたが、思い通りに機能していないようです。DIV の下部にある id="bob" で画像を中央に配置したいと思います。

私のHTMLは次のとおりです。

<table id="newsTable" width="100%" border="1">
  <thead>
     <tr>
       <th>
         <div onClick="openClose('2006')" style="cursor:hand; cursor:pointer">
              Title
              <img id="20062" src="images/play.png" style="float:right;">
         </div>
       </th>
     </tr>
   </thead>
   <tbody>
     <tr>
        <td>
          <div id="2006" class="texter">
            <h2>Subtitle</h2>
              <img src="images/image.jpg" style="float:right;">
              <p>
                Some text
              </p>
              <div class="album">
                <div class="album-content">
                  <img id="bob" src="images/picture.jpg">
                </div>
              </div>
              <img style="float:left;" id="prev" src="images/left.gif">
              <img style="float:right;" id="next" src="images/right.gif">
          </div>
        </td>
      </tr>
    </tbody>
  </table>

次の CSS スタイルを使用します。

#newsTable {
    border: 1px solid #e3e3e3;
    width: 100%;
    border-radius: 6px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
}

#newsTable td, #newsTable th {
    padding: 5px;
    color: #333;
}

#newsTable td {
    line-height: 20px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 12px;
    border: 0px solid;  
    font-weight: bold;
}

#newsTable thead {
    font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    font-size:18px;
    padding: .2em 0 .2em .5em;
    text-align: left;
    color: #4B4B4B;
    background: transparant;
    border-bottom: solid 1px #999;
}

#newsTable th {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-image:url(images/background_thead.jpg);
    background-repeat: no-repeat; 
    font-size: 18px;
    line-height: 25px;
    font-style: normal;
    font-weight: normal;
    text-align: left;
    text-shadow: white 1px 1px 1px;
}

.texter {
    display:none
}

@media print {
    .texter {
       display:block;
    }
}

.album {
    height: 600px;
    position: relative;
}

.album-content {
    position: absolute;
    bottom: 0;
    float: none;
    text-align:center;
}

私はほとんどすべてを試しましたが、id="bob" の IMG を中央に移動するものは何もないようです。CSSのどの部分が画像を左に保持しているのか誰か教えてもらえますか?

4

3 に答える 3

1

.album-contentdivは絶対的に配置されているため、親コンテナの幅は採用されません。したがって、画像の幅と同じ幅になります。widthまたはを設定するか、leftおよびrightプロパティを設定する必要があります。

どちらか

.album-content {
    position   : absolute;
    bottom     : 0;
    left       : 0;
    right      : 0;
    text-align : center;
}

または

.album-content {
    position   : absolute;
    bottom     : 0;
    width      : 100%;
    text-align : center;
}
于 2013-02-25T19:37:44.873 に答える
1

スタイルの後に引用符がありません:<img style="float:right; id="next" src="images/right.gif">

于 2013-02-25T18:45:12.260 に答える
0

@ user2108340 css を次のように変更します

 .album-content {
    width:100%;
    position: absolute;
    bottom: 0;
    text-align:center;

    }
于 2013-02-25T18:46:22.307 に答える