0

次のhtmlコードがあります。

<ul class="ul">
   <li class="li">
        <a href="#;" class="a">Link</a>
        <div class="div"> <img src="photo.jpg" /> </div>
    </li>
</ul>

そして、次の CSS:

ul.ul {
   background-image: url(text.png);
   background-repeat: no-repeat;
   background-position: 100% 0;  
   >li.li{
    height: 80px;
    min-width: 68px;

    background-repeat: no-repeat;
    background-position: 50% (72px-32px-12px);
    color: #fff;

    >a {
        line-height:8px;
        margin-top: 12px;
        color: #fff;
        font-weight: bold;
        padding-bottom: 10px;
        height: (80/2+14);
    }

    >div.div{
        text-align: center;
    } 

}

そして、私のdivは要素「a」の下にあり、要素aの上に置きたいです。firebug では、div が li の外にあるようです。何が悪いのか教えていただけますか?

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

4

2 に答える 2

0

with onlydivのクラス名を持つ a を持つことで、あなたが何を達成しようとしているのかわかりません。必要なテキストを中央に配置する場合は、. またはより良い解決策;divtext-align: center;uldiv

a {
    line-height:8px;
    margin-top: 12px;
    color: #fff;
    font-weight: bold;
    padding-bottom: 10px;
    height: 5px; /* Idk why you had that the way it was... thats not css */
    text-align: center;
}

あなたが何を望んでいるのかがわかったので、実際にあなたを助けることができます. 画像を中央に配置するには、次のようにします。

img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
于 2015-07-30T14:28:27.017 に答える