0

私のhtml:

<body>
    <div id="click-here">
        <a href="...">
            <span>Click here</span>
        </a>
    </div>
    ...
</body>

私のCSS:

html { 
    margin-top: 100px !important; 
}

#click-here { 
    height: 100px; 
    position: fixed; 
    top: 0;
    width: 100%; 
    z-index: 100000; 
}

#click-here a {
    background-image: url('...');
    display: block; 
    height: 60px; 
    width: 200px; 
    margin: 0 auto; 
    margin-top: 20px; 
    text-align: center; 
}

Click here を、ボタンとして機能する a 要素の中央に配置します。ただし、水平方向の中央揃えのみです。アンカーで vertical-align: middle を試しましたが、うまくいきませんでした。また、span に margin-top と padding-top を設定してみましたが、これは完全に無視されます。

他に何を試すことができるか考えていますか?

4

3 に答える 3

0

この jsfiddle を参照してください: http://jsfiddle.net/PeSFh/ using display: table, display: table-celland vertical-align: middle.

于 2013-07-30T15:31:04.270 に答える